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); |
} |