<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210122] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210122">210122</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-12-22 16:20:27 -0800 (Thu, 22 Dec 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Nested calls to setDocument can omit firing 'unload' events
https://bugs.webkit.org/show_bug.cgi?id=166422
<rdar://problem/29763012>
Reviewed by Alex Christensen.
Source/WebCore:
Test: fast/loader/nested-document-handling.html
Only allow a single document change to be taking place during a given runloop cycle.
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::executeIfJavaScriptURL): Block script changing the document
when we are in the middle of changing the document.
* page/Frame.cpp:
(WebCore::Frame::setDocument): Keep track of document change state.
* page/Frame.h:
LayoutTests:
* fast/loader/nested-document-handling-expected.txt: Added.
* fast/loader/nested-document-handling.html: Added.
* fast/loader/resources/subframe-success.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentWritercpp">trunk/Source/WebCore/loader/DocumentWriter.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameh">trunk/Source/WebCore/page/Frame.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastloadernesteddocumenthandlingexpectedtxt">trunk/LayoutTests/fast/loader/nested-document-handling-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastloadernesteddocumenthandlinghtml">trunk/LayoutTests/fast/loader/nested-document-handling.html</a></li>
<li><a href="#trunkLayoutTestsfastloaderresourcessubframesuccesshtml">trunk/LayoutTests/fast/loader/resources/subframe-success.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210121 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-22 23:52:44 UTC (rev 210121)
+++ trunk/LayoutTests/ChangeLog        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-12-22 Brent Fulgham <bfulgham@apple.com>
+
+ Nested calls to setDocument can omit firing 'unload' events
+ https://bugs.webkit.org/show_bug.cgi?id=166422
+ <rdar://problem/29763012>
+
+ Reviewed by Alex Christensen.
+
+ * fast/loader/nested-document-handling-expected.txt: Added.
+ * fast/loader/nested-document-handling.html: Added.
+ * fast/loader/resources/subframe-success.html: Added.
+
</ins><span class="cx"> 2016-12-22 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><span class="cx"> Do not destroy the RenderNamedFlowFragment as leftover anonymous block.
</span></span></pre></div>
<a id="trunkLayoutTestsfastloadernesteddocumenthandlingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/nested-document-handling-expected.txt (0 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/nested-document-handling-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/loader/nested-document-handling-expected.txt        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Check that we properly handle nested document loads during unload events. Passes if we do not debug assert.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Load succeeded.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastloadernesteddocumenthandlinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/nested-document-handling.html (0 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/nested-document-handling.html         (rev 0)
+++ trunk/LayoutTests/fast/loader/nested-document-handling.html        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script>
+"use strict";
+
+description('Check that we properly handle nested document loads during unload events. Passes if we do not debug assert.');
+
+window.jsTestIsAsync = true;
+
+function finishTest() {
+ testPassed('Load succeeded.');
+ finishJSTest();
+}
+
+function runTest() {
+ let topFrame = document.documentElement.appendChild(document.createElement("iframe"));
+ topFrame.id = 'topFrame';
+
+ let aFrame = topFrame.contentDocument.documentElement.appendChild(document.createElement("iframe"));
+ aFrame.id = 'aFrame';
+
+ aFrame.contentWindow.onunload = () => {
+ topFrame.src = "javascript:''";
+
+ let bFrame = topFrame.contentDocument.appendChild(document.createElement("iframe"));
+ bFrame.id = 'bFrame';
+
+ bFrame.contentWindow.onunload = () => {
+ topFrame.src = "javascript:''";
+
+ let doc = topFrame.contentDocument;
+
+ topFrame.onload = () => {
+ topFrame.onload = () => {
+ topFrame.onload = null;
+ let s = doc.createElement("form");
+ s.action = "javascript:alert(location)";
+ s.submit();
+ };
+
+ topFrame.src = "resources/subframe-success.html";
+ };
+
+ };
+ };
+
+ topFrame.src = "javascript:''";
+}
+</script>
+</head>
+<body onload="runTest()">
+</body>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastloaderresourcessubframesuccesshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/loader/resources/subframe-success.html (0 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/loader/resources/subframe-success.html         (rev 0)
+++ trunk/LayoutTests/fast/loader/resources/subframe-success.html        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<html>
+<body onload="parent.finishTest();">
+I am a simple document that completes the test when loaded
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210121 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-22 23:52:44 UTC (rev 210121)
+++ trunk/Source/WebCore/ChangeLog        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-12-22 Brent Fulgham <bfulgham@apple.com>
+
+ Nested calls to setDocument can omit firing 'unload' events
+ https://bugs.webkit.org/show_bug.cgi?id=166422
+ <rdar://problem/29763012>
+
+ Reviewed by Alex Christensen.
+
+ Test: fast/loader/nested-document-handling.html
+
+ Only allow a single document change to be taking place during a given runloop cycle.
+
+ * bindings/js/ScriptController.cpp:
+ (WebCore::ScriptController::executeIfJavaScriptURL): Block script changing the document
+ when we are in the middle of changing the document.
+ * page/Frame.cpp:
+ (WebCore::Frame::setDocument): Keep track of document change state.
+ * page/Frame.h:
+
</ins><span class="cx"> 2016-12-22 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> TileGrid creates new cohorts even when not using temporarilyRetainTileCohorts mode
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentWritercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (210121 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentWriter.cpp        2016-12-22 23:52:44 UTC (rev 210121)
+++ trunk/Source/WebCore/loader/DocumentWriter.cpp        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -73,6 +73,12 @@
</span><span class="cx"> void DocumentWriter::replaceDocument(const String& source, Document* ownerDocument)
</span><span class="cx"> {
</span><span class="cx"> m_frame->loader().stopAllLoaders();
</span><ins>+
+ // If we are in the midst of changing the frame's document, don't execute script
+ // that modifes the document further:
+ if (m_frame->documentIsBeingReplaced())
+ return;
+
</ins><span class="cx"> begin(m_frame->document()->url(), true, ownerDocument);
</span><span class="cx">
</span><span class="cx"> // begin() might fire an unload event, which will result in a situation where no new document has been attached,
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (210121 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp        2016-12-22 23:52:44 UTC (rev 210121)
+++ trunk/Source/WebCore/page/Frame.cpp        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -268,6 +268,11 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!newDocument || newDocument->frame() == this);
</span><span class="cx">
</span><ins>+ if (m_documentIsBeingReplaced)
+ return;
+
+ m_documentIsBeingReplaced = true;
+
</ins><span class="cx"> if (m_doc && m_doc->pageCacheState() != Document::InPageCache)
</span><span class="cx"> m_doc->prepareForDestruction();
</span><span class="cx">
</span><span class="lines">@@ -281,6 +286,8 @@
</span><span class="cx"> newDocument->didBecomeCurrentDocumentInFrame();
</span><span class="cx">
</span><span class="cx"> InspectorInstrumentation::frameDocumentUpdated(*this);
</span><ins>+
+ m_documentIsBeingReplaced = false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ORIENTATION_EVENTS)
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.h (210121 => 210122)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.h        2016-12-22 23:52:44 UTC (rev 210121)
+++ trunk/Source/WebCore/page/Frame.h        2016-12-23 00:20:27 UTC (rev 210122)
</span><span class="lines">@@ -155,6 +155,8 @@
</span><span class="cx"> WEBCORE_EXPORT RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
</span><span class="cx"> WEBCORE_EXPORT RenderWidget* ownerRenderer() const; // Renderer for the element that contains this frame.
</span><span class="cx">
</span><ins>+ bool documentIsBeingReplaced() const { return m_documentIsBeingReplaced; }
+
</ins><span class="cx"> // ======== All public functions below this point are candidates to move out of Frame into another class. ========
</span><span class="cx">
</span><span class="cx"> void injectUserScripts(UserScriptInjectionTime);
</span><span class="lines">@@ -318,6 +320,7 @@
</span><span class="cx">
</span><span class="cx"> int m_activeDOMObjectsAndAnimationsSuspendedCount;
</span><span class="cx"> bool m_mainFrameWasDestroyed { false };
</span><ins>+ bool m_documentIsBeingReplaced { false };
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> std::unique_ptr<EventHandler> m_eventHandler;
</span></span></pre>
</div>
</div>
</body>
</html>