Skip to content

Commit e252c2e

Browse files
authored
Add support for WorkerOptions attributes type and credentials (#2656)
1 parent 8f874c8 commit e252c2e

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

crates/web-sys/src/features/gen_WorkerOptions.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ impl WorkerOptions {
1919
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
2020
ret
2121
}
22+
#[cfg(feature = "RequestCredentials")]
23+
#[doc = "Change the `credentials` field of this object."]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `RequestCredentials`, `WorkerOptions`*"]
26+
pub fn credentials(&mut self, val: RequestCredentials) -> &mut Self {
27+
use wasm_bindgen::JsValue;
28+
let r = ::js_sys::Reflect::set(
29+
self.as_ref(),
30+
&JsValue::from("credentials"),
31+
&JsValue::from(val),
32+
);
33+
debug_assert!(
34+
r.is_ok(),
35+
"setting properties should never fail on our dictionary objects"
36+
);
37+
let _ = r;
38+
self
39+
}
2240
#[doc = "Change the `name` field of this object."]
2341
#[doc = ""]
2442
#[doc = "*This API requires the following crate features to be activated: `WorkerOptions`*"]
@@ -32,6 +50,20 @@ impl WorkerOptions {
3250
let _ = r;
3351
self
3452
}
53+
#[cfg(feature = "WorkerType")]
54+
#[doc = "Change the `type` field of this object."]
55+
#[doc = ""]
56+
#[doc = "*This API requires the following crate features to be activated: `WorkerOptions`, `WorkerType`*"]
57+
pub fn type_(&mut self, val: WorkerType) -> &mut Self {
58+
use wasm_bindgen::JsValue;
59+
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val));
60+
debug_assert!(
61+
r.is_ok(),
62+
"setting properties should never fail on our dictionary objects"
63+
);
64+
let _ = r;
65+
self
66+
}
3567
}
3668
impl Default for WorkerOptions {
3769
fn default() -> Self {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![allow(unused_imports)]
2+
use wasm_bindgen::prelude::*;
3+
#[wasm_bindgen]
4+
#[doc = "The `WorkerType` enum."]
5+
#[doc = ""]
6+
#[doc = "*This API requires the following crate features to be activated: `WorkerType`*"]
7+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8+
pub enum WorkerType {
9+
Classic = "classic",
10+
Module = "module",
11+
}

crates/web-sys/src/features/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8140,6 +8140,12 @@ mod gen_WorkerOptions;
81408140
#[cfg(feature = "WorkerOptions")]
81418141
pub use gen_WorkerOptions::*;
81428142

8143+
#[cfg(feature = "WorkerType")]
8144+
#[allow(non_snake_case)]
8145+
mod gen_WorkerType;
8146+
#[cfg(feature = "WorkerType")]
8147+
pub use gen_WorkerType::*;
8148+
81438149
#[cfg(feature = "Worklet")]
81448150
#[allow(non_snake_case)]
81458151
mod gen_Worklet;

crates/web-sys/webidls/enabled/Worker.webidl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ interface Worker : EventTarget {
2727
Worker includes AbstractWorker;
2828

2929
dictionary WorkerOptions {
30-
// WorkerType type = "classic"; TODO: Bug 1247687
31-
// RequestCredentials credentials = "omit"; // credentials is only used if type is "module" TODO: Bug 1247687
30+
WorkerType type = "classic";
31+
RequestCredentials credentials = "omit"; // credentials is only used if type is "module"
3232
DOMString name = "";
3333
};
3434

35+
enum WorkerType { "classic", "module" };
36+
3537
[Constructor(USVString scriptURL),
3638
Func="mozilla::dom::ChromeWorker::WorkerAvailable",
3739
Exposed=(Window,DedicatedWorker,SharedWorker,System)]

0 commit comments

Comments
 (0)