Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Unified Diff: Source/core/dom/ContainerNode.cpp

Issue 1277793002: parserRemoveChild: Avoid unintended DOM modifications after user script run (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/parser/scriptexec-during-parserRemoveChild-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index ef20bb6ea9237c822c4032474b4d2f068026a3a3..1c46d51413199c8ad2d3c3974aa7b102cd3afeb1 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -620,15 +620,18 @@ void ContainerNode::parserRemoveChild(Node& oldChild)
ASSERT(oldChild.parentNode() == this);
ASSERT(!oldChild.isDocumentFragment());
- Node* prev = oldChild.previousSibling();
- Node* next = oldChild.nextSibling();
-
+ // This may cause arbitrary Javascript execution via onunload handlers.
if (oldChild.connectedSubframeCount())
ChildFrameDisconnector(oldChild).disconnect();
+ if (oldChild.parentNode() != this)
+ return;
+
ChildListMutationScope(*this).willRemoveChild(oldChild);
oldChild.notifyMutationObserversNodeWillDetach();
+ Node* prev = oldChild.previousSibling();
+ Node* next = oldChild.nextSibling();
removeBetween(prev, next, oldChild);
notifyNodeRemoved(oldChild);
« no previous file with comments | « LayoutTests/fast/parser/scriptexec-during-parserRemoveChild-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698