Skip to content

Commit

Permalink
Add support for WorkerOptions attributes type and credentials (#2656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ofenhed committed Aug 16, 2021
1 parent 8f874c8 commit e252c2e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
32 changes: 32 additions & 0 deletions crates/web-sys/src/features/gen_WorkerOptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ impl WorkerOptions {
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(feature = "RequestCredentials")]
#[doc = "Change the `credentials` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RequestCredentials`, `WorkerOptions`*"]
pub fn credentials(&mut self, val: RequestCredentials) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("credentials"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `WorkerOptions`*"]
Expand All @@ -32,6 +50,20 @@ impl WorkerOptions {
let _ = r;
self
}
#[cfg(feature = "WorkerType")]
#[doc = "Change the `type` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `WorkerOptions`, `WorkerType`*"]
pub fn type_(&mut self, val: WorkerType) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
impl Default for WorkerOptions {
fn default() -> Self {
Expand Down
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_WorkerType.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![allow(unused_imports)]
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
#[doc = "The `WorkerType` enum."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `WorkerType`*"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WorkerType {
Classic = "classic",
Module = "module",
}
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8140,6 +8140,12 @@ mod gen_WorkerOptions;
#[cfg(feature = "WorkerOptions")]
pub use gen_WorkerOptions::*;

#[cfg(feature = "WorkerType")]
#[allow(non_snake_case)]
mod gen_WorkerType;
#[cfg(feature = "WorkerType")]
pub use gen_WorkerType::*;

#[cfg(feature = "Worklet")]
#[allow(non_snake_case)]
mod gen_Worklet;
Expand Down
6 changes: 4 additions & 2 deletions crates/web-sys/webidls/enabled/Worker.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ interface Worker : EventTarget {
Worker includes AbstractWorker;

dictionary WorkerOptions {
// WorkerType type = "classic"; TODO: Bug 1247687
// RequestCredentials credentials = "omit"; // credentials is only used if type is "module" TODO: Bug 1247687
WorkerType type = "classic";
RequestCredentials credentials = "omit"; // credentials is only used if type is "module"
DOMString name = "";
};

enum WorkerType { "classic", "module" };

[Constructor(USVString scriptURL),
Func="mozilla::dom::ChromeWorker::WorkerAvailable",
Exposed=(Window,DedicatedWorker,SharedWorker,System)]
Expand Down

0 comments on commit e252c2e

Please sign in to comment.