Commit 22bf150b authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Move context document/frame null checks earlier

- It is better to do nothing when context document/frame is null.
- Preparation for removing ExecuteScriptResult.
  kShouldFireNone is no longer used, and will be removed in
  https://chromium-review.googlesource.com/791473.

Bug: 788828, 686281
Change-Id: I2327e9065c9a07da0ea3658bb1d31765cbcb537f
Reviewed-on: https://chromium-review.googlesource.com/791450
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521926}
parent 5a1ce5c8
......@@ -742,12 +742,10 @@ ScriptLoader::ExecuteScriptResult ScriptLoader::DoExecuteScript(
Document* element_document = &(element_->GetDocument());
Document* context_document = element_document->ContextDocument();
if (!context_document)
return ExecuteScriptResult::kShouldFireNone;
DCHECK(context_document);
LocalFrame* frame = context_document->GetFrame();
if (!frame)
return ExecuteScriptResult::kShouldFireNone;
DCHECK(frame);
if (!is_external_script_) {
bool should_bypass_main_world_csp =
......@@ -833,6 +831,19 @@ void ScriptLoader::ExecuteScriptBlock(PendingScript* pending_script,
DCHECK(pending_script);
DCHECK_EQ(pending_script->IsExternal(), is_external_script_);
Document* element_document = &(element_->GetDocument());
Document* context_document = element_document->ContextDocument();
if (!context_document) {
pending_script->Dispose();
return;
}
LocalFrame* frame = context_document->GetFrame();
if (!frame) {
pending_script->Dispose();
return;
}
bool error_occurred = false;
Script* script = pending_script->GetSource(document_url, error_occurred);
const bool was_canceled = pending_script->WasCanceled();
......@@ -843,8 +854,6 @@ void ScriptLoader::ExecuteScriptBlock(PendingScript* pending_script,
// Do not execute module scripts if they are moved between documents.
// TODO(hiroshige): Also do not execute classic scripts. crbug.com/721914
Document* element_document = &(element_->GetDocument());
Document* context_document = element_document->ContextDocument();
if (original_document_ != context_document &&
GetScriptType() == ScriptType::kModule)
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment