Commit 4fd241c9 authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[ContentIndex] Check SW reg execution context before using it

The crash report seems to imply that this can be null, although I'm
still unsure when that would happen.

Bug: 1150628, 1143619
Change-Id: Ifceb52846deaab48ec749ee11992b3c586ecbcb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550182
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829267}
parent 6af16a3e
......@@ -118,14 +118,22 @@ void ContentIndex::DidGetIconSizes(
ScriptPromiseResolver* resolver,
mojom::blink::ContentDescriptionPtr description,
const Vector<gfx::Size>& icon_sizes) {
ScriptState* script_state = resolver->GetScriptState();
ScriptState::Scope scope(script_state);
if (!icon_sizes.IsEmpty() && description->icons.IsEmpty()) {
ScriptState* script_state = resolver->GetScriptState();
ScriptState::Scope scope(script_state);
resolver->Reject(V8ThrowException::CreateTypeError(
script_state->GetIsolate(), "icons must be provided"));
return;
}
if (!registration_->GetExecutionContext()) {
// The SW execution context is not valid for some reason. Bail out.
resolver->Reject(V8ThrowException::CreateTypeError(
script_state->GetIsolate(), "Service worker is no longer valid."));
return;
}
if (icon_sizes.IsEmpty()) {
DidGetIcons(resolver, std::move(description), /* icons= */ {});
return;
......@@ -152,6 +160,13 @@ void ContentIndex::DidGetIcons(ScriptPromiseResolver* resolver,
}
}
if (!registration_->GetExecutionContext()) {
// The SW execution context is not valid for some reason. Bail out.
resolver->Reject(V8ThrowException::CreateTypeError(
script_state->GetIsolate(), "Service worker is no longer valid."));
return;
}
KURL launch_url = registration_->GetExecutionContext()->CompleteURL(
description->launch_url);
......
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