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

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

Issue 798493005: Merge 187458 "Correctly move script element to a detached document." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2214/
Patch Set: 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
===================================================================
--- Source/core/html/HTMLScriptElement.cpp (revision 187771)
+++ Source/core/html/HTMLScriptElement.cpp (working copy)
@@ -73,8 +73,17 @@
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) {
+ 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();
+ }
+ 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