diff --git a/CHANGELOG.md b/CHANGELOG.md index da6e2063ded..de77040a614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ proc-macro and accept the `--include-ignored` flag with `wasm-bindgen-test-runner`. [#3644](https://github.com/rustwasm/wasm-bindgen/pull/3644) +* Added missing additions to the Notification API. + [#3667](https://github.com/rustwasm/wasm-bindgen/pull/3667) + ### Changed * Updated the WebGPU WebIDL. @@ -154,6 +157,9 @@ * Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm. [#3582](https://github.com/rustwasm/wasm-bindgen/pull/3582) +* Removed `GetNotificationOptions`, `NotificationBehavior` and `Notification.get()` because + they don't exist anymore. + ## [0.2.87](https://github.com/rustwasm/wasm-bindgen/compare/0.2.86...0.2.87) Released 2023-06-12. diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 2163a277c6e..74d20795d79 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -444,7 +444,6 @@ GamepadPose = [] GamepadServiceTest = [] Geolocation = [] GetAnimationsOptions = [] -GetNotificationOptions = [] GetRootNodeOptions = [] GetUserMediaRequest = [] Gpu = [] @@ -880,7 +879,7 @@ NodeFilter = [] NodeIterator = [] NodeList = [] Notification = ["EventTarget"] -NotificationBehavior = [] +NotificationAction = [] NotificationDirection = [] NotificationEvent = ["Event", "ExtendableEvent"] NotificationEventInit = [] diff --git a/crates/web-sys/src/features/gen_GetNotificationOptions.rs b/crates/web-sys/src/features/gen_GetNotificationOptions.rs deleted file mode 100644 index ac6589dd67a..00000000000 --- a/crates/web-sys/src/features/gen_GetNotificationOptions.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![allow(unused_imports)] -#![allow(clippy::all)] -use super::*; -use wasm_bindgen::prelude::*; -#[wasm_bindgen] -extern "C" { - # [wasm_bindgen (extends = :: js_sys :: Object , js_name = GetNotificationOptions)] - #[derive(Debug, Clone, PartialEq, Eq)] - #[doc = "The `GetNotificationOptions` dictionary."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GetNotificationOptions`*"] - pub type GetNotificationOptions; -} -impl GetNotificationOptions { - #[doc = "Construct a new `GetNotificationOptions`."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GetNotificationOptions`*"] - pub fn new() -> Self { - #[allow(unused_mut)] - let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); - ret - } - #[doc = "Change the `tag` field of this object."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GetNotificationOptions`*"] - pub fn tag(&mut self, val: &str) -> &mut Self { - use wasm_bindgen::JsValue; - let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("tag"), &JsValue::from(val)); - debug_assert!( - r.is_ok(), - "setting properties should never fail on our dictionary objects" - ); - let _ = r; - self - } -} -impl Default for GetNotificationOptions { - fn default() -> Self { - Self::new() - } -} diff --git a/crates/web-sys/src/features/gen_Notification.rs b/crates/web-sys/src/features/gen_Notification.rs index 857ad0089c5..b0eaed5e807 100644 --- a/crates/web-sys/src/features/gen_Notification.rs +++ b/crates/web-sys/src/features/gen_Notification.rs @@ -20,6 +20,13 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Notification`, `NotificationPermission`*"] pub fn permission() -> NotificationPermission; + # [wasm_bindgen (structural , static_method_of = Notification , getter , js_class = "Notification" , js_name = maxActions)] + #[doc = "Getter for the `maxActions` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/maxActions)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn max_actions() -> u32; # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = onclick)] #[doc = "Getter for the `onclick` field of this object."] #[doc = ""] @@ -112,6 +119,13 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Notification`*"] pub fn tag(this: &Notification) -> Option; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = image)] + #[doc = "Getter for the `image` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/image)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn image(this: &Notification) -> String; # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = icon)] #[doc = "Getter for the `icon` field of this object."] #[doc = ""] @@ -119,6 +133,41 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Notification`*"] pub fn icon(this: &Notification) -> Option; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = badge)] + #[doc = "Getter for the `badge` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/badge)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn badge(this: &Notification) -> String; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = vibrate)] + #[doc = "Getter for the `vibrate` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/vibrate)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn vibrate(this: &Notification) -> ::js_sys::Array; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = timestamp)] + #[doc = "Getter for the `timestamp` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/timestamp)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn timestamp(this: &Notification) -> f64; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = renotify)] + #[doc = "Getter for the `renotify` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/renotify)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn renotify(this: &Notification) -> bool; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = silent)] + #[doc = "Getter for the `silent` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/silent)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn silent(this: &Notification) -> Option; # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = requireInteraction)] #[doc = "Getter for the `requireInteraction` field of this object."] #[doc = ""] @@ -133,6 +182,13 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Notification`*"] pub fn data(this: &Notification) -> ::wasm_bindgen::JsValue; + # [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = actions)] + #[doc = "Getter for the `actions` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/actions)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Notification`*"] + pub fn actions(this: &Notification) -> ::js_sys::Array; #[wasm_bindgen(catch, constructor, js_class = "Notification")] #[doc = "The `new Notification(..)` constructor, creating a new instance of `Notification`."] #[doc = ""] @@ -158,21 +214,6 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Notification`*"] pub fn close(this: &Notification); - # [wasm_bindgen (catch , static_method_of = Notification , js_class = "Notification" , js_name = get)] - #[doc = "The `get()` method."] - #[doc = ""] - #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/get)"] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `Notification`*"] - pub fn get() -> Result<::js_sys::Promise, JsValue>; - #[cfg(feature = "GetNotificationOptions")] - # [wasm_bindgen (catch , static_method_of = Notification , js_class = "Notification" , js_name = get)] - #[doc = "The `get()` method."] - #[doc = ""] - #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/get)"] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GetNotificationOptions`, `Notification`*"] - pub fn get_with_filter(filter: &GetNotificationOptions) -> Result<::js_sys::Promise, JsValue>; # [wasm_bindgen (catch , static_method_of = Notification , js_class = "Notification" , js_name = requestPermission)] #[doc = "The `requestPermission()` method."] #[doc = ""] diff --git a/crates/web-sys/src/features/gen_NotificationAction.rs b/crates/web-sys/src/features/gen_NotificationAction.rs new file mode 100644 index 00000000000..919e13c0f37 --- /dev/null +++ b/crates/web-sys/src/features/gen_NotificationAction.rs @@ -0,0 +1,65 @@ +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = NotificationAction)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `NotificationAction` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"] + pub type NotificationAction; +} +impl NotificationAction { + #[doc = "Construct a new `NotificationAction`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"] + pub fn new(action: &str, title: &str) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.action(action); + ret.title(title); + ret + } + #[doc = "Change the `action` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"] + pub fn action(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("action"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[doc = "Change the `icon` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"] + pub fn icon(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("icon"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[doc = "Change the `title` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"] + pub fn title(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("title"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_NotificationBehavior.rs b/crates/web-sys/src/features/gen_NotificationBehavior.rs deleted file mode 100644 index 0f11b7e4055..00000000000 --- a/crates/web-sys/src/features/gen_NotificationBehavior.rs +++ /dev/null @@ -1,113 +0,0 @@ -#![allow(unused_imports)] -#![allow(clippy::all)] -use super::*; -use wasm_bindgen::prelude::*; -#[wasm_bindgen] -extern "C" { - # [wasm_bindgen (extends = :: js_sys :: Object , js_name = NotificationBehavior)] - #[derive(Debug, Clone, PartialEq, Eq)] - #[doc = "The `NotificationBehavior` dictionary."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub type NotificationBehavior; -} -impl NotificationBehavior { - #[doc = "Construct a new `NotificationBehavior`."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub fn new() -> Self { - #[allow(unused_mut)] - let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); - ret - } - #[doc = "Change the `noclear` field of this object."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub fn noclear(&mut self, val: bool) -> &mut Self { - use wasm_bindgen::JsValue; - let r = ::js_sys::Reflect::set( - self.as_ref(), - &JsValue::from("noclear"), - &JsValue::from(val), - ); - debug_assert!( - r.is_ok(), - "setting properties should never fail on our dictionary objects" - ); - let _ = r; - self - } - #[doc = "Change the `noscreen` field of this object."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub fn noscreen(&mut self, val: bool) -> &mut Self { - use wasm_bindgen::JsValue; - let r = ::js_sys::Reflect::set( - self.as_ref(), - &JsValue::from("noscreen"), - &JsValue::from(val), - ); - debug_assert!( - r.is_ok(), - "setting properties should never fail on our dictionary objects" - ); - let _ = r; - self - } - #[doc = "Change the `showOnlyOnce` field of this object."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub fn show_only_once(&mut self, val: bool) -> &mut Self { - use wasm_bindgen::JsValue; - let r = ::js_sys::Reflect::set( - self.as_ref(), - &JsValue::from("showOnlyOnce"), - &JsValue::from(val), - ); - debug_assert!( - r.is_ok(), - "setting properties should never fail on our dictionary objects" - ); - let _ = r; - self - } - #[doc = "Change the `soundFile` field of this object."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub fn sound_file(&mut self, val: &str) -> &mut Self { - use wasm_bindgen::JsValue; - let r = ::js_sys::Reflect::set( - self.as_ref(), - &JsValue::from("soundFile"), - &JsValue::from(val), - ); - debug_assert!( - r.is_ok(), - "setting properties should never fail on our dictionary objects" - ); - let _ = r; - self - } - #[doc = "Change the `vibrationPattern` field of this object."] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `NotificationBehavior`*"] - pub fn vibration_pattern(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { - use wasm_bindgen::JsValue; - let r = ::js_sys::Reflect::set( - self.as_ref(), - &JsValue::from("vibrationPattern"), - &JsValue::from(val), - ); - debug_assert!( - r.is_ok(), - "setting properties should never fail on our dictionary objects" - ); - let _ = r; - self - } -} -impl Default for NotificationBehavior { - fn default() -> Self { - Self::new() - } -} diff --git a/crates/web-sys/src/features/gen_NotificationOptions.rs b/crates/web-sys/src/features/gen_NotificationOptions.rs index 31d504db744..ec01ac68a66 100644 --- a/crates/web-sys/src/features/gen_NotificationOptions.rs +++ b/crates/web-sys/src/features/gen_NotificationOptions.rs @@ -20,6 +20,36 @@ impl NotificationOptions { let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); ret } + #[doc = "Change the `actions` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] + pub fn actions(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("actions"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[doc = "Change the `badge` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] + pub fn badge(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("badge"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } #[doc = "Change the `body` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] @@ -73,6 +103,19 @@ impl NotificationOptions { let _ = r; self } + #[doc = "Change the `image` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] + pub fn image(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("image"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } #[doc = "Change the `lang` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] @@ -86,6 +129,23 @@ impl NotificationOptions { let _ = r; self } + #[doc = "Change the `renotify` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] + pub fn renotify(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("renotify"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } #[doc = "Change the `requireInteraction` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] @@ -103,6 +163,20 @@ impl NotificationOptions { let _ = r; self } + #[doc = "Change the `silent` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] + pub fn silent(&mut self, val: Option) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("silent"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } #[doc = "Change the `tag` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] @@ -116,6 +190,23 @@ impl NotificationOptions { let _ = r; self } + #[doc = "Change the `timestamp` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `NotificationOptions`*"] + pub fn timestamp(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("timestamp"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } } impl Default for NotificationOptions { fn default() -> Self { diff --git a/crates/web-sys/src/features/gen_ServiceWorkerRegistration.rs b/crates/web-sys/src/features/gen_ServiceWorkerRegistration.rs index 1923ab849c6..5556ea0303b 100644 --- a/crates/web-sys/src/features/gen_ServiceWorkerRegistration.rs +++ b/crates/web-sys/src/features/gen_ServiceWorkerRegistration.rs @@ -84,17 +84,6 @@ extern "C" { pub fn get_notifications( this: &ServiceWorkerRegistration, ) -> Result<::js_sys::Promise, JsValue>; - #[cfg(feature = "GetNotificationOptions")] - # [wasm_bindgen (catch , method , structural , js_class = "ServiceWorkerRegistration" , js_name = getNotifications)] - #[doc = "The `getNotifications()` method."] - #[doc = ""] - #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/getNotifications)"] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GetNotificationOptions`, `ServiceWorkerRegistration`*"] - pub fn get_notifications_with_filter( - this: &ServiceWorkerRegistration, - filter: &GetNotificationOptions, - ) -> Result<::js_sys::Promise, JsValue>; # [wasm_bindgen (catch , method , structural , js_class = "ServiceWorkerRegistration" , js_name = showNotification)] #[doc = "The `showNotification()` method."] #[doc = ""] diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index 9a3bb1d99c1..12094200303 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -2476,12 +2476,6 @@ mod gen_GetAnimationsOptions; #[cfg(feature = "GetAnimationsOptions")] pub use gen_GetAnimationsOptions::*; -#[cfg(feature = "GetNotificationOptions")] -#[allow(non_snake_case)] -mod gen_GetNotificationOptions; -#[cfg(feature = "GetNotificationOptions")] -pub use gen_GetNotificationOptions::*; - #[cfg(feature = "GetRootNodeOptions")] #[allow(non_snake_case)] mod gen_GetRootNodeOptions; @@ -5092,11 +5086,11 @@ mod gen_Notification; #[cfg(feature = "Notification")] pub use gen_Notification::*; -#[cfg(feature = "NotificationBehavior")] +#[cfg(feature = "NotificationAction")] #[allow(non_snake_case)] -mod gen_NotificationBehavior; -#[cfg(feature = "NotificationBehavior")] -pub use gen_NotificationBehavior::*; +mod gen_NotificationAction; +#[cfg(feature = "NotificationAction")] +pub use gen_NotificationAction::*; #[cfg(feature = "NotificationDirection")] #[allow(non_snake_case)] diff --git a/crates/web-sys/webidls/enabled/Notification.webidl b/crates/web-sys/webidls/enabled/Notification.webidl index 7d63d9732b3..3114b8cd909 100644 --- a/crates/web-sys/webidls/enabled/Notification.webidl +++ b/crates/web-sys/webidls/enabled/Notification.webidl @@ -1,60 +1,34 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * https://notifications.spec.whatwg.org/ - * - * Copyright: - * To the extent possible under law, the editors have waived all copyright and - * related or neighboring rights to this work. - */ - -[Constructor(DOMString title, optional NotificationOptions options), - Exposed=(Window,Worker), - Func="mozilla::dom::Notification::PrefEnabled"] +[Exposed=(Window,Worker)] interface Notification : EventTarget { - [GetterThrows] + constructor(DOMString title, optional NotificationOptions options = {}); + static readonly attribute NotificationPermission permission; [Throws, Func="mozilla::dom::Notification::RequestPermissionEnabledForScope"] static Promise requestPermission(optional NotificationPermissionCallback permissionCallback); - [Throws, Func="mozilla::dom::Notification::IsGetEnabled"] - static Promise> get(optional GetNotificationOptions filter); + static readonly attribute unsigned long maxActions; attribute EventHandler onclick; - attribute EventHandler onshow; - attribute EventHandler onerror; - attribute EventHandler onclose; - [Pure] readonly attribute DOMString title; - - [Pure] readonly attribute NotificationDirection dir; - - [Pure] readonly attribute DOMString? lang; - - [Pure] readonly attribute DOMString? body; - - [Constant] readonly attribute DOMString? tag; - - [Pure] - readonly attribute DOMString? icon; - - [Constant, Func="mozilla::dom::DOMPrefs::NotificationRIEnabled"] + readonly attribute USVString image; + readonly attribute USVString? icon; + readonly attribute USVString badge; + [SameObject] readonly attribute FrozenArray vibrate; + readonly attribute unsigned long long timestamp; + readonly attribute boolean renotify; + readonly attribute boolean? silent; readonly attribute boolean requireInteraction; - - [Constant] - readonly attribute any data; + [SameObject] readonly attribute any data; + [SameObject] readonly attribute FrozenArray actions; undefined close(); }; @@ -64,21 +38,15 @@ dictionary NotificationOptions { DOMString lang = ""; DOMString body = ""; DOMString tag = ""; - DOMString icon = ""; + USVString image; + USVString icon; + USVString badge; + unsigned long long timestamp; + boolean renotify = false; + boolean? silent = null; boolean requireInteraction = false; any data = null; -}; - -dictionary GetNotificationOptions { - DOMString tag = ""; -}; - -dictionary NotificationBehavior { - boolean noscreen = false; - boolean noclear = false; - boolean showOnlyOnce = false; - DOMString soundFile = ""; - sequence vibrationPattern; + sequence actions = []; }; enum NotificationPermission { @@ -87,10 +55,16 @@ enum NotificationPermission { "granted" }; -callback NotificationPermissionCallback = undefined (NotificationPermission permission); - enum NotificationDirection { "auto", "ltr", "rtl" }; + +dictionary NotificationAction { + required DOMString action; + required DOMString title; + USVString icon; +}; + +callback NotificationPermissionCallback = undefined (NotificationPermission permission);