Chromium Code Reviews| 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 ad91f9dc9d92335c7aeb0b8ea2deba54d71818dc..9e51e8c5bcb17dd6cdaf7920f70ddd6e1b33fbba 100644 |
| --- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp |
| +++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp |
| @@ -236,12 +236,21 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, |
| m_alreadyStarted = true; |
| + // FIXME: Eventually we'd like to evaluate scripts which are inserted into a |
| + // viewless document but this'll do for now. |
| + // See http://bugs.webkit.org/show_bug.cgi?id=5727 |
| // FIXME: If script is parser inserted, verify it's still in the original |
| // document. |
| Document& elementDocument = m_element->document(); |
| Document* contextDocument = elementDocument.contextDocument(); |
| + if (!contextDocument) |
| + return false; |
| - if (!contextDocument || !contextDocument->allowExecutingScripts(m_element)) |
| + LocalFrame* contextFrame = contextDocument->executingFrame(); |
| + if (!contextFrame) |
| + return false; |
| + LocalFrame* elementFrame = elementDocument.frame(); |
|
Yuki
2017/01/20 06:15:17
question: This was elementDocument.executingFrame(
kouhei (in TOK)
2017/01/20 06:19:03
No? We still use contextFrame to chck which is exe
Yuki
2017/01/20 06:24:36
Oops, I was misreading. Let me revise my question
|
| + if (!contextFrame->script().canExecuteScripts(AboutToExecuteScript)) |
| return false; |
| if (!isScriptForEventSupported()) |
| @@ -296,13 +305,16 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, |
| } else if (client->hasSourceAttribute()) { |
| m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
| m_asyncExecType = ScriptRunner::Async; |
| - LocalFrame* frame = m_element->document().frame(); |
| - if (frame) { |
| - ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| - if (scriptState) |
| + if (elementFrame) { |
| + // TODO(kouhei): I'm not sure below is correct. I think we should use |
| + // contextFrame rather than elementFrame. |
| + ScriptState* scriptState = ScriptState::forMainWorld(elementFrame); |
| + if (scriptState) { |
| ScriptStreamer::startStreaming( |
| - m_pendingScript.get(), ScriptStreamer::Async, frame->settings(), |
| - scriptState, frame->frameScheduler()->loadingTaskRunner()); |
| + m_pendingScript.get(), ScriptStreamer::Async, |
| + elementFrame->settings(), scriptState, |
| + elementFrame->frameScheduler()->loadingTaskRunner()); |
| + } |
| } |
| contextDocument->scriptRunner()->queueScriptForExecution(this, |
| m_asyncExecType); |