Title: [210353] branches/safari-603-branch

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210352 => 210353)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-01-05 17:09:30 UTC (rev 210352)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-01-05 17:09:34 UTC (rev 210353)
@@ -1,5 +1,21 @@
 2017-01-05  Matthew Hanson  <[email protected]>
 
+        Merge r210122. rdar://problem/29763012
+
+    2016-12-22  Brent Fulgham  <[email protected]>
+
+            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.
+
+2017-01-05  Matthew Hanson  <[email protected]>
+
         Merge r210120. rdar://problem/29772233
 
     2016-12-22  Zalan Bujtas  <[email protected]>

Added: branches/safari-603-branch/LayoutTests/fast/loader/nested-document-handling-expected.txt (0 => 210353)


--- branches/safari-603-branch/LayoutTests/fast/loader/nested-document-handling-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/loader/nested-document-handling-expected.txt	2017-01-05 17:09:34 UTC (rev 210353)
@@ -0,0 +1,10 @@
+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
+

Added: branches/safari-603-branch/LayoutTests/fast/loader/nested-document-handling.html (0 => 210353)


--- branches/safari-603-branch/LayoutTests/fast/loader/nested-document-handling.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/loader/nested-document-handling.html	2017-01-05 17:09:34 UTC (rev 210353)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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 = ""
+
+        let bFrame = topFrame.contentDocument.appendChild(document.createElement("iframe"));
+        bFrame.id = 'bFrame';
+
+        bFrame.contentWindow._onunload_ = () => {
+            topFrame.src = ""
+
+            let doc = topFrame.contentDocument;
+
+            topFrame._onload_ = () => {
+                topFrame._onload_ = () => {
+                    topFrame._onload_ = null;
+                    let s = doc.createElement("form");
+                    s.action = ""
+                    s.submit();
+                };
+
+                topFrame.src = ""
+            };
+
+        };
+    };
+
+    topFrame.src = ""
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>
\ No newline at end of file

Added: branches/safari-603-branch/LayoutTests/fast/loader/resources/subframe-success.html (0 => 210353)


--- branches/safari-603-branch/LayoutTests/fast/loader/resources/subframe-success.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/loader/resources/subframe-success.html	2017-01-05 17:09:34 UTC (rev 210353)
@@ -0,0 +1,5 @@
+<html>
+<body _onload_="parent.finishTest();">
+I am a simple document that completes the test when loaded
+</body>
+</html>

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210352 => 210353)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-05 17:09:30 UTC (rev 210352)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-05 17:09:34 UTC (rev 210353)
@@ -1,5 +1,28 @@
 2017-01-05  Matthew Hanson  <[email protected]>
 
+        Merge r210122. rdar://problem/29763012
+
+    2016-12-22  Brent Fulgham  <[email protected]>
+
+            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:
+
+2017-01-05  Matthew Hanson  <[email protected]>
+
         Merge r210120. rdar://problem/29772233
 
     2016-12-22  Zalan Bujtas  <[email protected]>

Modified: branches/safari-603-branch/Source/WebCore/loader/DocumentWriter.cpp (210352 => 210353)


--- branches/safari-603-branch/Source/WebCore/loader/DocumentWriter.cpp	2017-01-05 17:09:30 UTC (rev 210352)
+++ branches/safari-603-branch/Source/WebCore/loader/DocumentWriter.cpp	2017-01-05 17:09:34 UTC (rev 210353)
@@ -73,6 +73,12 @@
 void DocumentWriter::replaceDocument(const String& source, Document* ownerDocument)
 {
     m_frame->loader().stopAllLoaders();
+
+    // 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;
+
     begin(m_frame->document()->url(), true, ownerDocument);
 
     // begin() might fire an unload event, which will result in a situation where no new document has been attached,

Modified: branches/safari-603-branch/Source/WebCore/page/Frame.cpp (210352 => 210353)


--- branches/safari-603-branch/Source/WebCore/page/Frame.cpp	2017-01-05 17:09:30 UTC (rev 210352)
+++ branches/safari-603-branch/Source/WebCore/page/Frame.cpp	2017-01-05 17:09:34 UTC (rev 210353)
@@ -268,6 +268,11 @@
 {
     ASSERT(!newDocument || newDocument->frame() == this);
 
+    if (m_documentIsBeingReplaced)
+        return;
+
+    m_documentIsBeingReplaced = true;
+    
     if (m_doc && m_doc->pageCacheState() != Document::InPageCache)
         m_doc->prepareForDestruction();
 
@@ -281,6 +286,8 @@
         newDocument->didBecomeCurrentDocumentInFrame();
 
     InspectorInstrumentation::frameDocumentUpdated(*this);
+
+    m_documentIsBeingReplaced = false;
 }
 
 #if ENABLE(ORIENTATION_EVENTS)

Modified: branches/safari-603-branch/Source/WebCore/page/Frame.h (210352 => 210353)


--- branches/safari-603-branch/Source/WebCore/page/Frame.h	2017-01-05 17:09:30 UTC (rev 210352)
+++ branches/safari-603-branch/Source/WebCore/page/Frame.h	2017-01-05 17:09:34 UTC (rev 210353)
@@ -155,6 +155,8 @@
     WEBCORE_EXPORT RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
     WEBCORE_EXPORT RenderWidget* ownerRenderer() const; // Renderer for the element that contains this frame.
 
+    bool documentIsBeingReplaced() const { return m_documentIsBeingReplaced; }
+
 // ======== All public functions below this point are candidates to move out of Frame into another class. ========
 
     void injectUserScripts(UserScriptInjectionTime);
@@ -318,6 +320,7 @@
 
     int m_activeDOMObjectsAndAnimationsSuspendedCount;
     bool m_mainFrameWasDestroyed { false };
+    bool m_documentIsBeingReplaced { false };
 
 protected:
     std::unique_ptr<EventHandler> m_eventHandler;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to