1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://notifications.spec.whatwg.org/ 8 * 9 * Copyright: 10 * To the extent possible under law, the editors have waived all copyright and 11 * related or neighboring rights to this work. 12 */ 13 14[Constructor(DOMString title, optional NotificationOptions options), 15 Exposed=(Window,Worker), 16 Func="mozilla::dom::Notification::PrefEnabled"] 17interface Notification : EventTarget { 18 [GetterThrows] 19 static readonly attribute NotificationPermission permission; 20 21 [Throws, Func="mozilla::dom::Notification::RequestPermissionEnabledForScope"] 22 static Promise<NotificationPermission> requestPermission(optional NotificationPermissionCallback permissionCallback); 23 24 [Throws, Func="mozilla::dom::Notification::IsGetEnabled"] 25 static Promise<sequence<Notification>> get(optional GetNotificationOptions filter); 26 27 attribute EventHandler onclick; 28 29 attribute EventHandler onshow; 30 31 attribute EventHandler onerror; 32 33 attribute EventHandler onclose; 34 35 [Pure] 36 readonly attribute DOMString title; 37 38 [Pure] 39 readonly attribute NotificationDirection dir; 40 41 [Pure] 42 readonly attribute DOMString? lang; 43 44 [Pure] 45 readonly attribute DOMString? body; 46 47 [Constant] 48 readonly attribute DOMString? tag; 49 50 [Pure] 51 readonly attribute DOMString? icon; 52 53 [Constant, Func="mozilla::dom::DOMPrefs::NotificationRIEnabled"] 54 readonly attribute boolean requireInteraction; 55 56 [Constant] 57 readonly attribute any data; 58 59 undefined close(); 60}; 61 62dictionary NotificationOptions { 63 NotificationDirection dir = "auto"; 64 DOMString lang = ""; 65 DOMString body = ""; 66 DOMString tag = ""; 67 DOMString icon = ""; 68 boolean requireInteraction = false; 69 any data = null; 70}; 71 72dictionary GetNotificationOptions { 73 DOMString tag = ""; 74}; 75 76dictionary NotificationBehavior { 77 boolean noscreen = false; 78 boolean noclear = false; 79 boolean showOnlyOnce = false; 80 DOMString soundFile = ""; 81 sequence<unsigned long> vibrationPattern; 82}; 83 84enum NotificationPermission { 85 "default", 86 "denied", 87 "granted" 88}; 89 90callback NotificationPermissionCallback = undefined (NotificationPermission permission); 91 92enum NotificationDirection { 93 "auto", 94 "ltr", 95 "rtl" 96}; 97