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

Unified Diff: Source/core/html/HTMLScriptElement.cpp

Issue 809323002: Correctly move script element to a detached document. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test Created 6 years 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/dom/HTMLScriptElement/script-element-moved-to-detached-document-crash-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/html/HTMLScriptElement.cpp
diff --git a/Source/core/html/HTMLScriptElement.cpp b/Source/core/html/HTMLScriptElement.cpp
index 6bfccd19b5be16247a313ae4f1ef572071062f46..bce71bdbcb9686e604a03408401a08950b6eeb5f 100644
--- a/Source/core/html/HTMLScriptElement.cpp
+++ b/Source/core/html/HTMLScriptElement.cpp
@@ -73,8 +73,17 @@ void HTMLScriptElement::childrenChanged(const ChildrenChange& change)
void HTMLScriptElement::didMoveToNewDocument(Document& oldDocument)
{
- if (RefPtrWillBeRawPtr<Document> contextDocument = document().contextDocument().get())
- oldDocument.scriptRunner()->movePendingAsyncScript(contextDocument->scriptRunner(), m_loader.get());
+ RefPtrWillBeRawPtr<Document> contextDocument = document().contextDocument().get();
+ if (!contextDocument) {
haraken 2014/12/18 14:30:22 I'd slightly prefer: RefPtrWillBeRawPtr<Document>
sof 2014/12/30 11:00:51 Thanks for bringing this up. That wouldn't be quit
+ ASSERT(!document().frame());
+ // A frame-detached document is handled as having no context
+ // document - it would be the document if not detached. The
+ // newly moved script element needs to be the latter here as
+ // the script loader for the pending script must also move to
+ // reside with that document and its script runner.
+ contextDocument = &document();
marja 2014/12/18 10:27:47 In this case, is oldDocument also the same as docu
sof 2014/12/18 10:29:37 No, higher up in the node adoption handling checks
+ }
+ oldDocument.scriptRunner()->movePendingAsyncScript(contextDocument->scriptRunner(), m_loader.get());
HTMLElement::didMoveToNewDocument(oldDocument);
}
« no previous file with comments | « LayoutTests/fast/dom/HTMLScriptElement/script-element-moved-to-detached-document-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698