-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Implement worker modules
Josh Matthews edited this page Feb 17, 2020
·
1 revision
Background information: Major browsers support worker JavaScript modules which support more complex JS module integration than classic Web Workers. Servo is a new, experimental browser that supports Web Workers and non-worker JS module scripts; the goal of this project is implement support for worker module scripts.
Tracking issue: (please ask questions in these issues)
Useful references:
- Guide to getting Servo building
- Documentation for types and modules inside Servo
- Pull request that added support for non-worker module scripts
Initial steps:
- email the mozilla.dev.servo mailing list (be sure to subscribe to it first!) introducing your group and asking any necessary questions
- restructure worker creation to avoid synchronously waiting for an initial worker script
- in
run_worker_scope
incomponents/script/dom/dedicatedworkerglobalscope.rs
, extract theRequestBuilder
creation andload_whole_resource
call into a separate function calledfetch_a_classic_worker_script
- add a
ScriptLoaded
variant toWorkerScriptMessage
incomponents/script/dom/abstractworker.rs
which stores aResult<(Url, String), String>
value - update
DedicatedWorkerGlobalScope::handle_script_event
to deal with the new event type - move thescope.execute_script
call out ofrun_worker_scope
when a script loaded successfully, and move the error handling out of the return value ofload_whole_resource
when an error is passed instead - make the new
fetch_a_classic_worker_script
function queue aScriptLoaded
event when either an error occurs or the script loads successfully
- in
Subsequent steps:
- create initial failing test results for worker module automated tests
- remove these lines
-
update the test expectations for
tests/wpt/web-platform-tests/workers/modules
)
- implement the
unimplemented!
worker branch inModuleOwner::finish_module_load
:- duplicate whatever code is necessary from the Window branch to add
is_top_level
handling for worker modules that calls a method on theDedicatedWorkerGlobalScope
that queues theScriptLoaded
event - once that works as expected, refactor both branches to share as much code as possible without duplication
- duplicate whatever code is necessary from the Window branch to add
- verify that the automated tests are producing more reasonable successful results and update the test expectations again