| Index: third_party/WebKit/Source/core/dom/ScriptLoader.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
|
| index 803253989b2fe8626add173db2851c50234da2b1..f55a0262b356ba140891f47c113734fc84d72433 100644
|
| --- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
|
| @@ -60,6 +60,7 @@ namespace blink {
|
| ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadyStarted)
|
| : m_element(element)
|
| , m_resource(0)
|
| + , m_originWorldId(0)
|
| , m_startLineNumber(WTF::OrdinalNumber::beforeFirst())
|
| , m_parserInserted(parserInserted)
|
| , m_isExternalScript(false)
|
| @@ -240,6 +241,12 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy
|
| return false;
|
| }
|
|
|
| + // Store the origin to apply when the script is done loading, as the script could be loaded in the main world.
|
| + if (v8::Isolate::GetCurrent()->InContext()) {
|
| + DOMWrapperWorld& creatingWorld = DOMWrapperWorld::current(v8::Isolate::GetCurrent());
|
| + m_originWorldId = creatingWorld.originWorldId();
|
| + }
|
| +
|
| if (client->hasSourceAttribute() && client->deferAttributeValue() && m_parserInserted && !client->asyncAttributeValue()) {
|
| m_willExecuteWhenDocumentFinishedParsing = true;
|
| m_willBeParserExecuted = true;
|
| @@ -415,6 +422,9 @@ bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com
|
| if (isHTMLScriptLoader(m_element))
|
| contextDocument->pushCurrentScript(toHTMLScriptElement(m_element));
|
|
|
| + // Ensure the parent world id gets propagated to the script and is reset afterwards.
|
| + DOMWrapperWorld::ParentWorldIdPusher worldIdPusher(ScriptState::forMainWorld(frame)->world(), m_originWorldId);
|
| +
|
| // Create a script from the script element node, using the script
|
| // block's source and the script block's type.
|
| // Note: This is where the script is compiled and actually executed.
|
|
|