- Revision
- 212354
- Author
- [email protected]
- Date
- 2017-02-15 01:57:28 -0800 (Wed, 15 Feb 2017)
Log Message
An assertion failure inside removeChildren
https://bugs.webkit.org/show_bug.cgi?id=168069
Reviewed by Brent Fulgham.
Source/WebCore:
The bug was caused by notifyRemovePendingSheet executing scripts synchronously where it shouldn't.
Removed the call to notifyRemovePendingSheetIfNeeded in notifyChildNodeRemoved. Instead, invoke it
in its call sites when they're safe.
Test: http/tests/security/move-iframe-within-focus-handler-inside-removal.html
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::takeAllChildrenFrom):
(WebCore::ContainerNode::notifyChildInserted):
(WebCore::ContainerNode::removeChild):
(WebCore::ContainerNode::parserRemoveChild):
(WebCore::ContainerNode::replaceAllChildren):
(WebCore::ContainerNode::removeChildren):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::notifyChildNodeRemoved):
LayoutTests:
* http/tests/security/move-iframe-within-focus-handler-inside-removal-expected.txt: Added.
* http/tests/security/move-iframe-within-focus-handler-inside-removal.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (212353 => 212354)
--- trunk/LayoutTests/ChangeLog 2017-02-15 08:58:23 UTC (rev 212353)
+++ trunk/LayoutTests/ChangeLog 2017-02-15 09:57:28 UTC (rev 212354)
@@ -1,3 +1,13 @@
+2017-02-14 Ryosuke Niwa <[email protected]>
+
+ An assertion failure inside removeChildren
+ https://bugs.webkit.org/show_bug.cgi?id=168069
+
+ Reviewed by Brent Fulgham.
+
+ * http/tests/security/move-iframe-within-focus-handler-inside-removal-expected.txt: Added.
+ * http/tests/security/move-iframe-within-focus-handler-inside-removal.html: Added.
+
2017-02-14 Brent Fulgham <[email protected]>
Revalidate URL after events that could trigger navigations
Added: trunk/LayoutTests/http/tests/security/move-iframe-within-focus-handler-inside-removal-expected.txt (0 => 212354)
--- trunk/LayoutTests/http/tests/security/move-iframe-within-focus-handler-inside-removal-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/security/move-iframe-within-focus-handler-inside-removal-expected.txt 2017-02-15 09:57:28 UTC (rev 212354)
@@ -0,0 +1,11 @@
+Tests moving an iframe inside a focus event handler while removing a node.
+To manually test, open this page on a new window/tab each time. Reloading would not work.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS newGlobal is not oldGlobal
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/security/move-iframe-within-focus-handler-inside-removal.html (0 => 212354)
--- trunk/LayoutTests/http/tests/security/move-iframe-within-focus-handler-inside-removal.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/move-iframe-within-focus-handler-inside-removal.html 2017-02-15 09:57:28 UTC (rev 212354)
@@ -0,0 +1,44 @@
+<html>
+<body>
+<script src=""
+<script>
+
+description(`Tests moving an iframe inside a focus event handler while removing a node.<br>
+<strong>To manually test, open this page on a new window/tab each time. Reloading would not work.</strong>`);
+
+const iframe = document.createElement('iframe');
+document.body.appendChild(iframe);
+const doc = iframe.contentDocument;
+
+doc.body.innerHTML = `<a id="target" href="" rel="stylesheet" href=""
+let target = doc.querySelector('#target');
+const linkParent = doc.querySelector('link').parentNode;
+
+window.movedFrame = doc.createElement('iframe');
+const helperFrame = doc.createElement('iframe');
+doc.body.appendChild(helperFrame);
+
+target._onfocus_ = () => {
+ linkParent.appendChild(movedFrame);
+ const helperContent = `<svg xmlns="http://www.w3.org/2000/svg"><script>top.check();<\/script></svg>`;
+ helperFrame.src = "" Blob([helperContent], {type: 'text/xml'}));
+};
+
+function check() {
+ window.oldGlobal = movedFrame.contentWindow;
+ doc.body.appendChild(movedFrame);
+ window.newGlobal = movedFrame.contentWindow;
+ shouldNotBe('newGlobal', 'oldGlobal');
+ iframe.remove();
+ finishJSTest();
+}
+
+iframe.contentWindow.location.hash = target.id;
+linkParent.textContent = '';
+
+var jsTestIsAsync = true;
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (212353 => 212354)
--- trunk/Source/WebCore/ChangeLog 2017-02-15 08:58:23 UTC (rev 212353)
+++ trunk/Source/WebCore/ChangeLog 2017-02-15 09:57:28 UTC (rev 212354)
@@ -1,3 +1,27 @@
+2017-02-14 Ryosuke Niwa <[email protected]>
+
+ An assertion failure inside removeChildren
+ https://bugs.webkit.org/show_bug.cgi?id=168069
+
+ Reviewed by Brent Fulgham.
+
+ The bug was caused by notifyRemovePendingSheet executing scripts synchronously where it shouldn't.
+
+ Removed the call to notifyRemovePendingSheetIfNeeded in notifyChildNodeRemoved. Instead, invoke it
+ in its call sites when they're safe.
+
+ Test: http/tests/security/move-iframe-within-focus-handler-inside-removal.html
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::takeAllChildrenFrom):
+ (WebCore::ContainerNode::notifyChildInserted):
+ (WebCore::ContainerNode::removeChild):
+ (WebCore::ContainerNode::parserRemoveChild):
+ (WebCore::ContainerNode::replaceAllChildren):
+ (WebCore::ContainerNode::removeChildren):
+ * dom/ContainerNodeAlgorithms.cpp:
+ (WebCore::notifyChildNodeRemoved):
+
2017-02-15 Carlos Garcia Campos <[email protected]>
[GStreamer] Several tests are timing out after r212349
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (212353 => 212354)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2017-02-15 08:58:23 UTC (rev 212353)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2017-02-15 09:57:28 UTC (rev 212354)
@@ -145,6 +145,8 @@
childrenChanged(change);
}
+ document().notifyRemovePendingSheetIfNeeded();
+
// FIXME: assert that we don't dispatch events here since this container node is still disconnected.
for (auto& child : children) {
RELEASE_ASSERT(!child->parentNode() && &child->treeScope() == &treeScope());
@@ -362,6 +364,9 @@
childrenChanged(change);
+ // Some call sites may have deleted child nodes. Calling it earlier results in bugs like webkit.org/b/168069.
+ document().notifyRemovePendingSheetIfNeeded();
+
for (auto& target : postInsertionNotificationTargets)
target->finishedInsertingSubtree();
}
@@ -549,6 +554,7 @@
notifyChildRemoved(child, prev, next, ChildChangeSourceAPI);
}
+ document().notifyRemovePendingSheetIfNeeded();
rebuildSVGExtensionsElementsIfNecessary();
dispatchSubtreeModifiedEvent();
@@ -609,6 +615,7 @@
removeBetween(prev, next, oldChild);
notifyChildRemoved(oldChild, prev, next, ChildChangeSourceParser);
+ document().notifyRemovePendingSheetIfNeeded();
}
// https://dom.spec.whatwg.org/#concept-node-replace-all
@@ -702,6 +709,7 @@
childrenChanged(change);
}
+ document().notifyRemovePendingSheetIfNeeded();
rebuildSVGExtensionsElementsIfNecessary();
dispatchSubtreeModifiedEvent();
}
Modified: trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp (212353 => 212354)
--- trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp 2017-02-15 08:58:23 UTC (rev 212353)
+++ trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp 2017-02-15 09:57:28 UTC (rev 212354)
@@ -159,7 +159,6 @@
return;
}
notifyNodeRemovedFromDocument(insertionPoint, child);
- child.document().notifyRemovePendingSheetIfNeeded();
}
void addChildNodesToDeletionQueue(Node*& head, Node*& tail, ContainerNode& container)