Commit ca9190d2 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

OMT service worker fetch: Set global scope's URL for installed script

When the main script is already installed, ServiceWorkerGlobalScope
retrieves the installed script from InstalledScriptsManager and
bypass WorkerGlobalScope::DidImportClassicScript(). Since the URL
of the global scope is set in DidImportClassicScript(), we need to
set the URL when we bypass the method.

This CL is a kind of workaround the cause though. Ideally we
should fix the issue by refactoring
ServiceWorkerGlobalScope::EvaluateClassicScriptInternal() so that
we don't use InstalledScriptsManager in it.

This CL fixes following NetworkServiceRestartBrowserTests:
- FetchFromServiceWorkerControlledPage_RespondWithFetch
- ServiceWorkerFetch

Bug: 924043
Change-Id: I1189e086ae8d878d32a6a1edd0d7209a1076f526
Reviewed-on: https://chromium-review.googlesource.com/c/1496116
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636706}
parent 4b0726fb
...@@ -33,8 +33,10 @@ ...@@ -33,8 +33,10 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/feature_list.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h" #include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h"
...@@ -311,6 +313,9 @@ void ServiceWorkerGlobalScope::EvaluateClassicScriptInternal( ...@@ -311,6 +313,9 @@ void ServiceWorkerGlobalScope::EvaluateClassicScriptInternal(
} }
// Receive the main script via script streaming if needed. // Receive the main script via script streaming if needed.
// TODO(nhiroki): Merge script loading from the installed script manager
// into regular off-the-main-thread script fetch path so that we can remove
// this special casing.
InstalledScriptsManager* installed_scripts_manager = InstalledScriptsManager* installed_scripts_manager =
GetThread()->GetInstalledScriptsManager(); GetThread()->GetInstalledScriptsManager();
if (installed_scripts_manager && if (installed_scripts_manager &&
...@@ -326,6 +331,14 @@ void ServiceWorkerGlobalScope::EvaluateClassicScriptInternal( ...@@ -326,6 +331,14 @@ void ServiceWorkerGlobalScope::EvaluateClassicScriptInternal(
return; return;
} }
if (base::FeatureList::IsEnabled(
features::kOffMainThreadServiceWorkerScriptFetch)) {
// WorkerGlobalScope sets the URL in DidImportClassicScript() when
// off-the-main-thread fetch is enabled. Since we bypass calling
// DidImportClassicScript(), set the URL here.
InitializeURL(script_url);
}
DCHECK(source_code.IsEmpty()); DCHECK(source_code.IsEmpty());
DCHECK(!cached_meta_data); DCHECK(!cached_meta_data);
source_code = script_data->TakeSourceText(); source_code = script_data->TakeSourceText();
......
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