-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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_scopeincomponents/script/dom/dedicatedworkerglobalscope.rs, extract theRequestBuildercreation andload_whole_resourcecall into a separate function calledfetch_a_classic_worker_script - add a
ScriptLoadedvariant toWorkerScriptMessageincomponents/script/dom/abstractworker.rswhich stores aResult<(Url, String), String>value - update
DedicatedWorkerGlobalScope::handle_script_eventto deal with the new event type - move thescope.execute_scriptcall out ofrun_worker_scopewhen a script loaded successfully, and move the error handling out of the return value ofload_whole_resourcewhen an error is passed instead - make the new
fetch_a_classic_worker_scriptfunction queue aScriptLoadedevent 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_levelhandling for worker modules that calls a method on theDedicatedWorkerGlobalScopethat queues theScriptLoadedevent - 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