Project: chromium Issues People Development process History Sign in
New issue
Advanced search Search tips
Starred by 9 users
Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment
Implement "module" workers
Project Member Reported by nhiroki@chromium.org, Jan 11 2017 Back to list
Specs of Dedicated/Shared/ServiceWorkers define "module" type.

  let worker = new Worker("worker.js", { type: "module" });

In this type, worker scripts are loaded as ES6 modules and import statement is available on the worker contexts. If the second parameter is omitted, worker scripts are loaded as plain scripts as usual ("classic" type).

Spec of Dedicated/SharedWorkers:
https://html.spec.whatwg.org/multipage/workers.html#module-worker-example

Spec of ServiceWorkers (see "type" in the section):
https://w3c.github.io/ServiceWorker/#service-worker-concept
 
 issue 627945  is for worklets.
Cc: neis@chromium.org
 Issue 739764  has been merged into this issue.
Cc: tzik@chromium.org
Relevant spec discussion:
"How can we use SW module link in backward-compatible manner?"
https://github.com/w3c/ServiceWorker/issues/1186
Project Member Comment 5 by bugdroid1@chromium.org, Oct 4
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/251d15052fedb579c071e9fe9b3d971b35c52214

commit 251d15052fedb579c071e9fe9b3d971b35c52214
Author: Hiroki Nakagawa <nhiroki@chromium.org>
Date: Wed Oct 04 08:46:29 2017

Worker: Clean up DedicatedWorker initialization

This is just a cleanup and doesn't change behavior.

The main change is to resolve a script URL before creating a DedicatedWorker
instance so that the instance doesn't take care of the case where the URL
resolution fails and the code path becomes simpler.

Bug: 680046
Change-Id: I439716e7cf562a1e71aafd453a76071179c9194c
Reviewed-on: https://chromium-review.googlesource.com/700094
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506339}
[modify] https://crrev.com/251d15052fedb579c071e9fe9b3d971b35c52214/third_party/WebKit/Source/core/workers/AbstractWorker.cpp
[modify] https://crrev.com/251d15052fedb579c071e9fe9b3d971b35c52214/third_party/WebKit/Source/core/workers/AbstractWorker.h
[modify] https://crrev.com/251d15052fedb579c071e9fe9b3d971b35c52214/third_party/WebKit/Source/core/workers/DedicatedWorker.cpp
[modify] https://crrev.com/251d15052fedb579c071e9fe9b3d971b35c52214/third_party/WebKit/Source/core/workers/DedicatedWorker.h
[modify] https://crrev.com/251d15052fedb579c071e9fe9b3d971b35c52214/third_party/WebKit/Source/core/workers/SharedWorker.cpp

Owner: nhiroki@chromium.org
Status: Started
Project Member Comment 7 by bugdroid1@chromium.org, Oct 5
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e4404c2f93e2d2ccacf15b07c834bff8051ddb63

commit e4404c2f93e2d2ccacf15b07c834bff8051ddb63
Author: Hiroki Nakagawa <nhiroki@chromium.org>
Date: Thu Oct 05 07:08:46 2017

ServiceWorker: Move InstalledScriptsManager access from WorkerThread to SWGlobalScope

For cleanup, this CL moves InstalledScriptsManager access from
WorkerThread::InitializeOnWorkerThread() to
ServiceWorkerGlobalScope::EvaluateClassicScript() because only ServiceWorker
needs to access the manager and placing it in EvaluateClassicScript() looks more
natural like importScripts().

<Motivation>

My final goal is to remove script evaluation code from WorkerThread and leave it
up to each owner of WorkerThread so that WorkerThead is no longer concerned with
how to evaluate scripts (i.e., "classic", "module", lazy eval for worklets).

For example, for DedicatedWorker, DedicatedWorkerMessagingProxy may post a task
to call WorkerGlobalScope::EvaluateClassicScript() or
WorkerGlobalScope::ImportModuleScript() (to be added later) based on
"WorkerType"[1] after initializing DedicatedWorkerThread.

[1] https://html.spec.whatwg.org/multipage/workers.html#workertype

Bug: 680046, 753350,  755054 
Change-Id: I546cbda16f09da66c3f94c319e498055e1f9d05b
Reviewed-on: https://chromium-review.googlesource.com/701854
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506670}
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/core/workers/WorkerGlobalScope.h
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/core/workers/WorkerThread.cpp
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeProxy.cpp
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerThread.cpp
[modify] https://crrev.com/e4404c2f93e2d2ccacf15b07c834bff8051ddb63/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerThread.h

Sign in to add a comment