Diff
Modified: trunk/LayoutTests/ChangeLog (210121 => 210122)
--- trunk/LayoutTests/ChangeLog 2016-12-22 23:52:44 UTC (rev 210121)
+++ trunk/LayoutTests/ChangeLog 2016-12-23 00:20:27 UTC (rev 210122)
@@ -1,3 +1,15 @@
+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.
+
2016-12-22 Zalan Bujtas <[email protected]>
Do not destroy the RenderNamedFlowFragment as leftover anonymous block.
Added: trunk/LayoutTests/fast/loader/nested-document-handling-expected.txt (0 => 210122)
--- 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)
@@ -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: trunk/LayoutTests/fast/loader/nested-document-handling.html (0 => 210122)
--- 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)
@@ -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: trunk/LayoutTests/fast/loader/resources/subframe-success.html (0 => 210122)
--- 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)
@@ -0,0 +1,5 @@
+<html>
+<body _onload_="parent.finishTest();">
+I am a simple document that completes the test when loaded
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (210121 => 210122)
--- 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)
@@ -1,3 +1,22 @@
+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:
+
2016-12-22 Tim Horton <[email protected]>
TileGrid creates new cohorts even when not using temporarilyRetainTileCohorts mode
Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (210121 => 210122)
--- 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)
@@ -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: trunk/Source/WebCore/page/Frame.cpp (210121 => 210122)
--- 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)
@@ -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: trunk/Source/WebCore/page/Frame.h (210121 => 210122)
--- 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)
@@ -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;