diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-05-11 03:36:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-11 03:36:23 -0400 |
commit | 965f57e3f8011dd7bdc61b438f95eeb87748319d (patch) | |
tree | 9f734fbc8f1f67e069d4555bbfcdf1ea84e5ca67 /components/script/dom/worker.rs | |
parent | d9559499b22bb4724f9b6108919f8d24bdbc83d9 (diff) | |
parent | dececad3905ccf8834abc37e71c7c1a8ac7542c7 (diff) | |
download | servo-965f57e3f8011dd7bdc61b438f95eeb87748319d.tar.gz servo-965f57e3f8011dd7bdc61b438f95eeb87748319d.zip |
Auto merge of #23309 - CYBAI:update-workers, r=nox
Support WorkerOptions for Worker
I'd like to start working on updating SW related codes and I found it will have some algorithms related to module workers. And I found parts of the spec update is related to [fetch a module worker script graph](https://html.spec.whatwg.org/multipage/#fetch-a-module-worker-script-tree), maybe it's worth being a separate PR?
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix part of #23308
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23309)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/worker.rs')
-rw-r--r-- | components/script/dom/worker.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 76eab2fb666..28b5715df89 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -5,13 +5,13 @@ use crate::dom::abstractworker::SimpleWorkerErrorHandler; use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::codegen::Bindings::WorkerBinding; -use crate::dom::bindings::codegen::Bindings::WorkerBinding::WorkerMethods; +use crate::dom::bindings::codegen::Bindings::WorkerBinding::{WorkerMethods, WorkerOptions}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; -use crate::dom::bindings::str::DOMString; +use crate::dom::bindings::str::USVString; use crate::dom::bindings::structuredclone::StructuredCloneData; use crate::dom::dedicatedworkerglobalscope::{ DedicatedWorkerGlobalScope, DedicatedWorkerScriptMsg, @@ -72,7 +72,11 @@ impl Worker { // https://html.spec.whatwg.org/multipage/#dom-worker #[allow(unsafe_code)] - pub fn Constructor(global: &GlobalScope, script_url: DOMString) -> Fallible<DomRoot<Worker>> { + pub fn Constructor( + global: &GlobalScope, + script_url: USVString, + worker_options: &WorkerOptions, + ) -> Fallible<DomRoot<Worker>> { // Step 2-4. let worker_url = match global.api_base_url().join(&script_url) { Ok(url) => url, @@ -118,6 +122,8 @@ impl Worker { sender, receiver, worker_load_origin, + String::from(&*worker_options.name), + worker_options.type_, closing, ); @@ -184,6 +190,9 @@ impl WorkerMethods for Worker { // https://html.spec.whatwg.org/multipage/#handler-worker-onmessage event_handler!(message, GetOnmessage, SetOnmessage); + // https://html.spec.whatwg.org/multipage/#handler-worker-onmessageerror + event_handler!(messageerror, GetOnmessageerror, SetOnmessageerror); + // https://html.spec.whatwg.org/multipage/#handler-workerglobalscope-onerror event_handler!(error, GetOnerror, SetOnerror); } |