| Index: Source/core/dom/ScriptRunner.cpp
|
| diff --git a/Source/core/dom/ScriptRunner.cpp b/Source/core/dom/ScriptRunner.cpp
|
| index 44543abd54da0b4edd9e54bbfd7b30a2b3f8d947..88ed1e1c360659213e8affaf7f2ffebd37670c3f 100644
|
| --- a/Source/core/dom/ScriptRunner.cpp
|
| +++ b/Source/core/dom/ScriptRunner.cpp
|
| @@ -118,6 +118,32 @@ void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
|
| }
|
| }
|
|
|
| +void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDocument, ScriptLoader* scriptLoader)
|
| +{
|
| + RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocument().get();
|
| + if (!newContextDocument) {
|
| + // Document's contextDocument() method will return no Document if the
|
| + // following conditions both hold:
|
| + //
|
| + // - The Document wasn't created with an explicit context document
|
| + // and that document is otherwise kept alive.
|
| + // - The Document itself is detached from its frame.
|
| + //
|
| + // The script element's loader is in that case moved to document() and
|
| + // its script runner, which is the non-null Document that contextDocument()
|
| + // would return if not detached.
|
| + ASSERT(!newDocument.frame());
|
| + newContextDocument = &newDocument;
|
| + }
|
| + RefPtrWillBeRawPtr<Document> oldContextDocument = oldDocument.contextDocument().get();
|
| + if (!oldContextDocument) {
|
| + ASSERT(!oldDocument.frame());
|
| + oldContextDocument = &oldDocument;
|
| + }
|
| + if (oldContextDocument != newContextDocument)
|
| + oldContextDocument->scriptRunner()->movePendingAsyncScript(newContextDocument->scriptRunner(), scriptLoader);
|
| +}
|
| +
|
| void ScriptRunner::movePendingAsyncScript(ScriptRunner* newRunner, ScriptLoader* scriptLoader)
|
| {
|
| if (m_pendingAsyncScripts.contains(scriptLoader)) {
|
|
|