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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2752673003: DOM: adoptNode() should not crash by reparenting the specified node in removeChild(). (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/dom/document/adoptNode-reparenting-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 exceptionState.throwDOMException( 1175 exceptionState.throwDOMException(
1176 HierarchyRequestError, 1176 HierarchyRequestError,
1177 "The node provided is a frame which contains this document."); 1177 "The node provided is a frame which contains this document.");
1178 return nullptr; 1178 return nullptr;
1179 } 1179 }
1180 } 1180 }
1181 if (source->parentNode()) { 1181 if (source->parentNode()) {
1182 source->parentNode()->removeChild(source, exceptionState); 1182 source->parentNode()->removeChild(source, exceptionState);
1183 if (exceptionState.hadException()) 1183 if (exceptionState.hadException())
1184 return nullptr; 1184 return nullptr;
1185 CHECK(!source->parentNode()); 1185 // The above removeChild() can execute arbitrary JavaScript code.
1186 if (source->parentNode()) {
1187 addConsoleMessage(ConsoleMessage::create(
1188 JSMessageSource, WarningMessageLevel,
1189 ExceptionMessages::failedToExecute("adoptNode", "Document",
1190 "Unable to remove the "
1191 "specified node from the "
1192 "original parent.")));
1193 return nullptr;
1194 }
1186 } 1195 }
1187 } 1196 }
1188 1197
1189 this->adoptIfNeeded(*source); 1198 this->adoptIfNeeded(*source);
1190 1199
1191 return source; 1200 return source;
1192 } 1201 }
1193 1202
1194 bool Document::hasValidNamespaceForElements(const QualifiedName& qName) { 1203 bool Document::hasValidNamespaceForElements(const QualifiedName& qName) {
1195 // These checks are from DOM Core Level 2, createElementNS 1204 // These checks are from DOM Core Level 2, createElementNS
(...skipping 5482 matching lines...) Expand 10 before | Expand all | Expand 10 after
6678 } 6687 }
6679 6688
6680 void showLiveDocumentInstances() { 6689 void showLiveDocumentInstances() {
6681 WeakDocumentSet& set = liveDocumentSet(); 6690 WeakDocumentSet& set = liveDocumentSet();
6682 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6691 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6683 for (blink::Document* document : set) 6692 for (blink::Document* document : set)
6684 fprintf(stderr, "- Document %p URL: %s\n", document, 6693 fprintf(stderr, "- Document %p URL: %s\n", document,
6685 document->url().getString().utf8().data()); 6694 document->url().getString().utf8().data());
6686 } 6695 }
6687 #endif 6696 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/dom/document/adoptNode-reparenting-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698