Skip to content

Commit

Permalink
SharedWorker: Handle parse error for module shared workers.
Browse files Browse the repository at this point in the history
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:
whatwg/html#5323

The wpt to check this feature will be added from external github:
web-platform-tests/wpt#22185


Bug: 1058259
Change-Id: I2397a7de8e2ae732fb0b29aea8d8703dd2a79a05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100058
Reviewed-by: Hiroki Nakagawa <[email protected]>
Commit-Queue: Eriko Kurimoto <[email protected]>
Cr-Commit-Position: refs/heads/master@{#753185}
  • Loading branch information
Eriko Kurimoto authored and Commit Bot committed Mar 25, 2020
1 parent 549e231 commit 283a686
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,15 @@ void SharedWorkerGlobalScope::DidFetchClassicScript(
const v8_inspector::V8StackTraceId& stack_id) {
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()) {
// 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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ void WorkerModuleTreeClient::NotifyModuleTreeLoadFinished(
blink::WorkerReportingProxy& worker_reporting_proxy =
worker_global_scope->ReportingProxy();

// Step 12. "If the algorithm asynchronously completes with null, then:"
if (!module_script) {
// Step 12. "If the algorithm asynchronously completes with null or with
// 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."
// DidFailToFetchModuleScript() will asynchronously fire the event.
worker_reporting_proxy.DidFailToFetchModuleScript();
Expand Down

0 comments on commit 283a686

Please sign in to comment.