Commit 283a686a authored by Eriko Kurimoto's avatar Eriko Kurimoto Committed by Commit Bot

SharedWorker: Handle parse error for module shared workers.

This CL handles parse error events in modules shared workers.
By this change, parse error events invoked by top-level scripts and
statically imported scripts can be handled by AbstractWorker.onerror.

The HTML spec defines script parsing should occur during the fetch step
and invoke a parse error event at that point if needed. This CL obeys
this behavior for module script workers, but not for classic script
workers because of an implementation reason that classic script workers
are supposed to parse the script during the evaluation step. Therefore,
the timing to catch parse error events differs.
In this CL, parse error handling is only implemented for module shared
workers, not for classic.

This is discussed in the html spec issue:
https://github.com/whatwg/html/issues/5323

The wpt to check this feature will be added from external github:
https://github.com/web-platform-tests/wpt/pull/22185


Bug: 1058259
Change-Id: I2397a7de8e2ae732fb0b29aea8d8703dd2a79a05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100058Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Eriko Kurimoto <elkurin@google.com>
Cr-Commit-Position: refs/heads/master@{#753185}
parent 549e2315
...@@ -214,7 +214,15 @@ void SharedWorkerGlobalScope::DidFetchClassicScript( ...@@ -214,7 +214,15 @@ void SharedWorkerGlobalScope::DidFetchClassicScript(
const v8_inspector::V8StackTraceId& stack_id) { const v8_inspector::V8StackTraceId& stack_id) {
DCHECK(IsContextThread()); DCHECK(IsContextThread());
// Step 12. "If the algorithm asynchronously completes with null, then:" // Step 12. "If the algorithm asynchronously completes with null or with
// script whose error to rethrow is non-null, then:"
//
// The case |error to rethrow| is non-null indicates the parse error.
// Parsing the script should be done during fetching according to the spec
// but it is done in EvaluateClassicScript() for classic scripts.
// Therefore, we cannot catch parse error events here.
// TODO(https://crbug.com/1058259) Catch parse error events for classic
// shared workers.
if (classic_script_loader->Failed()) { if (classic_script_loader->Failed()) {
// Step 12.1. "Queue a task to fire an event named error at worker." // Step 12.1. "Queue a task to fire an event named error at worker."
// Step 12.2. "Run the environment discarding steps for inside settings." // Step 12.2. "Run the environment discarding steps for inside settings."
......
...@@ -25,8 +25,9 @@ void WorkerModuleTreeClient::NotifyModuleTreeLoadFinished( ...@@ -25,8 +25,9 @@ void WorkerModuleTreeClient::NotifyModuleTreeLoadFinished(
blink::WorkerReportingProxy& worker_reporting_proxy = blink::WorkerReportingProxy& worker_reporting_proxy =
worker_global_scope->ReportingProxy(); worker_global_scope->ReportingProxy();
// Step 12. "If the algorithm asynchronously completes with null, then:" // Step 12. "If the algorithm asynchronously completes with null or with
if (!module_script) { // script whose error to rethrow is non-null, then:"
if (!module_script || module_script->HasErrorToRethrow()) {
// Step 12.1. "Queue a task to fire an event named error at worker." // Step 12.1. "Queue a task to fire an event named error at worker."
// DidFailToFetchModuleScript() will asynchronously fire the event. // DidFailToFetchModuleScript() will asynchronously fire the event.
worker_reporting_proxy.DidFailToFetchModuleScript(); worker_reporting_proxy.DidFailToFetchModuleScript();
......
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