Commit ff16abbf authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Worker: Hard-code AccessControlStatus for classic script evaluation in WorkerGlobalScope

This is a cleanup CL. Before this CL, AccessControlStatus for classic worker
scripts are passed from each worker implementation to WorkerGlobalScope.
Actually, however, AccessControlStatus::kSharableCrossOrigin is always specified
because cross-origin workers are disallowed. For cleanup, this CL stops passing
AccessControlStatus and instead hard-codes it in WorkerGlobalScope.

Bug: 835717
Change-Id: I9af910c113f1d5f032e77f48f54e1bc74153808b
Reviewed-on: https://chromium-review.googlesource.com/c/1304279
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603755}
parent ff9f2eda
...@@ -354,10 +354,9 @@ void WebSharedWorkerImpl::ContinueOnScriptLoaderFinished() { ...@@ -354,10 +354,9 @@ void WebSharedWorkerImpl::ContinueOnScriptLoaderFinished() {
thread_startup_data, DevToolsAgent::From(document), thread_startup_data, DevToolsAgent::From(document),
parent_execution_context_task_runners_); parent_execution_context_task_runners_);
// TODO(nhiroki): Support module workers (https://crbug.com/680046). // TODO(nhiroki): Support module workers (https://crbug.com/680046).
// Shared worker is origin-bound, so use kSharableCrossOrigin. GetWorkerThread()->EvaluateClassicScript(script_response_url, source_code,
GetWorkerThread()->EvaluateClassicScript( nullptr /* cached_meta_data */,
script_response_url, kSharableCrossOrigin, source_code, v8_inspector::V8StackTraceId());
nullptr /* cached_meta_data */, v8_inspector::V8StackTraceId());
client_->WorkerScriptLoaded(); client_->WorkerScriptLoaded();
} }
......
...@@ -55,10 +55,8 @@ void DedicatedWorkerMessagingProxy::StartWorkerGlobalScope( ...@@ -55,10 +55,8 @@ void DedicatedWorkerMessagingProxy::StartWorkerGlobalScope(
CreateBackingThreadStartupData(ToIsolate(GetExecutionContext()))); CreateBackingThreadStartupData(ToIsolate(GetExecutionContext())));
if (options.type() == "classic") { if (options.type() == "classic") {
// Dedicated worker is origin-bound, so use kSharableCrossOrigin.
GetWorkerThread()->EvaluateClassicScript( GetWorkerThread()->EvaluateClassicScript(
script_url, kSharableCrossOrigin, source_code, script_url, source_code, nullptr /* cached_meta_data */, stack_id);
nullptr /* cached_meta_data */, stack_id);
} else if (options.type() == "module") { } else if (options.type() == "module") {
network::mojom::FetchCredentialsMode credentials_mode; network::mojom::FetchCredentialsMode credentials_mode;
bool result = bool result =
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "third_party/blink/renderer/core/workers/worker_thread.h" #include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/core/workers/worker_thread_test_helper.h" #include "third_party/blink/renderer/core/workers/worker_thread_test_helper.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/loader/fetch/access_control_status.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h" #include "third_party/blink/renderer/platform/weborigin/security_policy.h"
...@@ -144,9 +143,9 @@ class DedicatedWorkerMessagingProxyForTest ...@@ -144,9 +143,9 @@ class DedicatedWorkerMessagingProxyForTest
WorkerBackingThreadStartupData( WorkerBackingThreadStartupData(
WorkerBackingThreadStartupData::HeapLimitMode::kDefault, WorkerBackingThreadStartupData::HeapLimitMode::kDefault,
WorkerBackingThreadStartupData::AtomicsWaitMode::kAllow)); WorkerBackingThreadStartupData::AtomicsWaitMode::kAllow));
GetWorkerThread()->EvaluateClassicScript( GetWorkerThread()->EvaluateClassicScript(script_url, source,
script_url, kOpaqueResource, source, nullptr /* cached_meta_data */, nullptr /* cached_meta_data */,
v8_inspector::V8StackTraceId()); v8_inspector::V8StackTraceId());
} }
DedicatedWorkerThreadForTest* GetDedicatedWorkerThread() { DedicatedWorkerThreadForTest* GetDedicatedWorkerThread() {
......
...@@ -324,22 +324,20 @@ void WorkerGlobalScope::TasksWereUnpaused() { ...@@ -324,22 +324,20 @@ void WorkerGlobalScope::TasksWereUnpaused() {
void WorkerGlobalScope::EvaluateClassicScriptPausable( void WorkerGlobalScope::EvaluateClassicScriptPausable(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data, std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id) { const v8_inspector::V8StackTraceId& stack_id) {
if (IsContextPaused()) { if (IsContextPaused()) {
AddPausedCall(WTF::Bind( AddPausedCall(WTF::Bind(&WorkerGlobalScope::EvaluateClassicScriptPausable,
&WorkerGlobalScope::EvaluateClassicScriptPausable, WrapWeakPersistent(this), script_url, source_code,
WrapWeakPersistent(this), script_url, access_control_status, WTF::Passed(std::move(cached_meta_data)),
source_code, WTF::Passed(std::move(cached_meta_data)), stack_id)); stack_id));
return; return;
} }
ThreadDebugger* debugger = ThreadDebugger::From(GetThread()->GetIsolate()); ThreadDebugger* debugger = ThreadDebugger::From(GetThread()->GetIsolate());
if (debugger) if (debugger)
debugger->ExternalAsyncTaskStarted(stack_id); debugger->ExternalAsyncTaskStarted(stack_id);
EvaluateClassicScript(script_url, access_control_status, source_code, EvaluateClassicScript(script_url, source_code, std::move(cached_meta_data));
std::move(cached_meta_data));
if (debugger) if (debugger)
debugger->ExternalAsyncTaskFinished(stack_id); debugger->ExternalAsyncTaskFinished(stack_id);
} }
...@@ -384,7 +382,6 @@ void WorkerGlobalScope::ReceiveMessagePausable( ...@@ -384,7 +382,6 @@ void WorkerGlobalScope::ReceiveMessagePausable(
void WorkerGlobalScope::EvaluateClassicScript( void WorkerGlobalScope::EvaluateClassicScript(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data) { std::unique_ptr<Vector<char>> cached_meta_data) {
DCHECK(IsContextThread()); DCHECK(IsContextThread());
...@@ -395,8 +392,9 @@ void WorkerGlobalScope::EvaluateClassicScript( ...@@ -395,8 +392,9 @@ void WorkerGlobalScope::EvaluateClassicScript(
ReportingProxy().WillEvaluateClassicScript( ReportingProxy().WillEvaluateClassicScript(
source_code.length(), source_code.length(),
cached_meta_data.get() ? cached_meta_data->size() : 0); cached_meta_data.get() ? cached_meta_data->size() : 0);
// Cross-origin workers are disallowed, so use kSharableCrossOrigin.
bool success = ScriptController()->Evaluate( bool success = ScriptController()->Evaluate(
ScriptSourceCode(source_code, handler, script_url), access_control_status, ScriptSourceCode(source_code, handler, script_url), kSharableCrossOrigin,
nullptr /* error_event */, v8_cache_options_); nullptr /* error_event */, v8_cache_options_);
ReportingProxy().DidEvaluateClassicScript(success); ReportingProxy().DidEvaluateClassicScript(success);
} }
......
...@@ -141,7 +141,6 @@ class CORE_EXPORT WorkerGlobalScope ...@@ -141,7 +141,6 @@ class CORE_EXPORT WorkerGlobalScope
// so that WorkerGlobalScope can be paused. // so that WorkerGlobalScope can be paused.
void EvaluateClassicScriptPausable( void EvaluateClassicScriptPausable(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data, std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id); const v8_inspector::V8StackTraceId& stack_id);
...@@ -184,7 +183,6 @@ class CORE_EXPORT WorkerGlobalScope ...@@ -184,7 +183,6 @@ class CORE_EXPORT WorkerGlobalScope
// Evaluates the given top-level classic script. // Evaluates the given top-level classic script.
virtual void EvaluateClassicScript( virtual void EvaluateClassicScript(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data); std::unique_ptr<Vector<char>> cached_meta_data);
......
...@@ -165,7 +165,6 @@ void WorkerThread::Start( ...@@ -165,7 +165,6 @@ void WorkerThread::Start(
void WorkerThread::EvaluateClassicScript( void WorkerThread::EvaluateClassicScript(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
const String& source_code, const String& source_code,
std::unique_ptr<Vector<char>> cached_meta_data, std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id) { const v8_inspector::V8StackTraceId& stack_id) {
...@@ -173,8 +172,7 @@ void WorkerThread::EvaluateClassicScript( ...@@ -173,8 +172,7 @@ void WorkerThread::EvaluateClassicScript(
PostCrossThreadTask( PostCrossThreadTask(
*GetTaskRunner(TaskType::kInternalWorker), FROM_HERE, *GetTaskRunner(TaskType::kInternalWorker), FROM_HERE,
CrossThreadBind(&WorkerThread::EvaluateClassicScriptOnWorkerThread, CrossThreadBind(&WorkerThread::EvaluateClassicScriptOnWorkerThread,
CrossThreadUnretained(this), script_url, CrossThreadUnretained(this), script_url, source_code,
access_control_status, source_code,
WTF::Passed(std::move(cached_meta_data)), stack_id)); WTF::Passed(std::move(cached_meta_data)), stack_id));
} }
...@@ -503,13 +501,11 @@ void WorkerThread::InitializeOnWorkerThread( ...@@ -503,13 +501,11 @@ void WorkerThread::InitializeOnWorkerThread(
void WorkerThread::EvaluateClassicScriptOnWorkerThread( void WorkerThread::EvaluateClassicScriptOnWorkerThread(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data, std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id) { const v8_inspector::V8StackTraceId& stack_id) {
To<WorkerGlobalScope>(GlobalScope()) To<WorkerGlobalScope>(GlobalScope())
->EvaluateClassicScriptPausable(script_url, access_control_status, ->EvaluateClassicScriptPausable(script_url, std::move(source_code),
std::move(source_code),
std::move(cached_meta_data), stack_id); std::move(cached_meta_data), stack_id);
} }
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "third_party/blink/renderer/core/inspector/devtools_agent.h" #include "third_party/blink/renderer/core/inspector/devtools_agent.h"
#include "third_party/blink/renderer/core/workers/parent_execution_context_task_runners.h" #include "third_party/blink/renderer/core/workers/parent_execution_context_task_runners.h"
#include "third_party/blink/renderer/core/workers/worker_backing_thread_startup_data.h" #include "third_party/blink/renderer/core/workers/worker_backing_thread_startup_data.h"
#include "third_party/blink/renderer/platform/loader/fetch/access_control_status.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/worker_scheduler.h" #include "third_party/blink/renderer/platform/scheduler/public/worker_scheduler.h"
#include "third_party/blink/renderer/platform/web_task_runner.h" #include "third_party/blink/renderer/platform/web_task_runner.h"
...@@ -107,7 +106,6 @@ class CORE_EXPORT WorkerThread : public Thread::TaskObserver { ...@@ -107,7 +106,6 @@ class CORE_EXPORT WorkerThread : public Thread::TaskObserver {
// Posts a task to evaluate a top-level classic script on the worker thread. // Posts a task to evaluate a top-level classic script on the worker thread.
// Called on the main thread after Start(). // Called on the main thread after Start().
void EvaluateClassicScript(const KURL& script_url, void EvaluateClassicScript(const KURL& script_url,
AccessControlStatus access_control_status,
const String& source_code, const String& source_code,
std::unique_ptr<Vector<char>> cached_meta_data, std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id); const v8_inspector::V8StackTraceId& stack_id);
...@@ -286,7 +284,6 @@ class CORE_EXPORT WorkerThread : public Thread::TaskObserver { ...@@ -286,7 +284,6 @@ class CORE_EXPORT WorkerThread : public Thread::TaskObserver {
void EvaluateClassicScriptOnWorkerThread( void EvaluateClassicScriptOnWorkerThread(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data, std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id); const v8_inspector::V8StackTraceId& stack_id);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "third_party/blink/renderer/core/workers/worker_thread.h" #include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/loader/fetch/access_control_status.h"
#include "third_party/blink/renderer/platform/network/content_security_policy_parsers.h" #include "third_party/blink/renderer/platform/network/content_security_policy_parsers.h"
#include "third_party/blink/renderer/platform/waitable_event.h" #include "third_party/blink/renderer/platform/waitable_event.h"
#include "third_party/blink/renderer/platform/web_thread_supporting_gc.h" #include "third_party/blink/renderer/platform/web_thread_supporting_gc.h"
...@@ -103,8 +102,7 @@ class WorkerThreadForTest : public WorkerThread { ...@@ -103,8 +102,7 @@ class WorkerThreadForTest : public WorkerThread {
Start(std::move(creation_params), Start(std::move(creation_params),
WorkerBackingThreadStartupData::CreateDefault(), nullptr, WorkerBackingThreadStartupData::CreateDefault(), nullptr,
parent_execution_context_task_runners); parent_execution_context_task_runners);
EvaluateClassicScript(script_url, kOpaqueResource, source, EvaluateClassicScript(script_url, source, nullptr /* cached_meta_data */,
nullptr /* cached_meta_data */,
v8_inspector::V8StackTraceId()); v8_inspector::V8StackTraceId());
} }
......
...@@ -466,10 +466,9 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() { ...@@ -466,10 +466,9 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() {
// > "classic": Fetch a classic worker script given job’s serialized script // > "classic": Fetch a classic worker script given job’s serialized script
// > url, job’s client, "serviceworker", and the to-be-created environment // > url, job’s client, "serviceworker", and the to-be-created environment
// > settings object for this service worker. // > settings object for this service worker.
// Service worker is origin-bound, so use kSharableCrossOrigin.
worker_thread_->EvaluateClassicScript( worker_thread_->EvaluateClassicScript(
worker_start_data_.script_url, kSharableCrossOrigin, source_code, worker_start_data_.script_url, source_code, std::move(cached_meta_data),
std::move(cached_meta_data), v8_inspector::V8StackTraceId()); v8_inspector::V8StackTraceId());
} else { } else {
// > "module": Fetch a module worker script graph given job’s serialized // > "module": Fetch a module worker script graph given job’s serialized
// > script url, job’s client, "serviceworker", "omit", and the // > script url, job’s client, "serviceworker", "omit", and the
......
...@@ -134,7 +134,6 @@ bool ServiceWorkerGlobalScope::ShouldInstallV8Extensions() const { ...@@ -134,7 +134,6 @@ bool ServiceWorkerGlobalScope::ShouldInstallV8Extensions() const {
void ServiceWorkerGlobalScope::EvaluateClassicScript( void ServiceWorkerGlobalScope::EvaluateClassicScript(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data) { std::unique_ptr<Vector<char>> cached_meta_data) {
DCHECK(IsContextThread()); DCHECK(IsContextThread());
...@@ -142,8 +141,8 @@ void ServiceWorkerGlobalScope::EvaluateClassicScript( ...@@ -142,8 +141,8 @@ void ServiceWorkerGlobalScope::EvaluateClassicScript(
if (!evaluate_script_ready_) { if (!evaluate_script_ready_) {
evaluate_script_ = evaluate_script_ =
WTF::Bind(&ServiceWorkerGlobalScope::EvaluateClassicScript, WTF::Bind(&ServiceWorkerGlobalScope::EvaluateClassicScript,
WrapWeakPersistent(this), script_url, access_control_status, WrapWeakPersistent(this), script_url, std::move(source_code),
std::move(source_code), std::move(cached_meta_data)); std::move(cached_meta_data));
return; return;
} }
...@@ -182,8 +181,7 @@ void ServiceWorkerGlobalScope::EvaluateClassicScript( ...@@ -182,8 +181,7 @@ void ServiceWorkerGlobalScope::EvaluateClassicScript(
ReportingProxy().DidLoadInstalledScript(); ReportingProxy().DidLoadInstalledScript();
} }
WorkerGlobalScope::EvaluateClassicScript(script_url, access_control_status, WorkerGlobalScope::EvaluateClassicScript(script_url, source_code,
source_code,
std::move(cached_meta_data)); std::move(cached_meta_data));
} }
......
...@@ -76,7 +76,6 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final : public WorkerGlobalScope { ...@@ -76,7 +76,6 @@ class MODULES_EXPORT ServiceWorkerGlobalScope final : public WorkerGlobalScope {
// Implements WorkerGlobalScope. // Implements WorkerGlobalScope.
void EvaluateClassicScript( void EvaluateClassicScript(
const KURL& script_url, const KURL& script_url,
AccessControlStatus access_control_status,
String source_code, String source_code,
std::unique_ptr<Vector<char>> cached_meta_data) override; std::unique_ptr<Vector<char>> cached_meta_data) override;
void ImportModuleScript( void ImportModuleScript(
......
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