diff --git a/notifications.bs b/notifications.bs index 90e3781..b968966 100644 --- a/notifications.bs +++ b/notifications.bs @@ -42,8 +42,9 @@ IDL, Service Workers, URL, and Vibration API Standards.
A notification is an abstract representation of something that happened, such as the delivery of a message. -
A notification can have an associated -service worker registration. +
A notification has an associated +service worker registration (null +or a service worker registration). It is initially null.
A notification has an associated title which is a string. @@ -156,35 +157,45 @@ corners or painting it in a specific color. Developers are encouraged to use an such cases gracefully and does not lose important information through, e.g., loss of color or clipped corners. -
A non-persistent notification is a -notification without an associated -service worker registration. +
A non-persistent notification is a notification whose +service worker registration is null. -
A persistent notification is a -notification with an associated -service worker registration. +
A persistent notification is a notification whose +service worker registration is non-null.
To create a notification, given a -string title, {{NotificationOptions}} dictionary options, -environment settings object settings, and optionally a -{{ServiceWorkerRegistration}} object serviceWorkerRegistration, run these steps: +
To create a notification with a settings object, given a string title, +{{NotificationOptions}} dictionary options, and +environment settings object settings:
Let notification be a new notification. +
Let origin be settings's + origin. + +
Let baseURL be settings's + API base URL. -
If a serviceWorkerRegistration was provided, then set notification's - service worker registration to serviceWorkerRegistration. +
Let fallbackTimestamp be the number of milliseconds from the Unix epoch to + settings's current wall time, rounded to the + nearest integer. -
If a serviceWorkerRegistration was not provided and - options["{{NotificationOptions/actions}}"] is not empty, then - throw a {{TypeError}}. +
Return the result of creating a notification given title, + options, origin, baseURL, and fallbackTimestamp. +
Actions are only currently supported for persistent notifications. +
To create a notification, given a string title, +{{NotificationOptions}} dictionary options, an origin +origin, a URL baseURL, and an {{EpochTimeStamp}} +fallbackTimestamp: + +
Let notification be a new notification.
If options["{{NotificationOptions/silent}}"] is true and
options["{{NotificationOptions/vibrate}}"] exists, then throw a
@@ -205,8 +216,7 @@ string title, {{NotificationOptions}} dictionary op
Set notification's language to
options["{{NotificationOptions/lang}}"].
- Set notification's origin to origin.
Set notification's body to
options["{{NotificationOptions/body}}"].
@@ -214,9 +224,6 @@ string title, {{NotificationOptions}} dictionary op
Set notification's tag to
options["{{NotificationOptions/tag}}"].
- Let baseURL be settings's
- API base URL.
-
If options["{{NotificationOptions/image}}"] exists, then
parse it using baseURL, and if that does not return failure, set
notification's image URL to the return value. (Otherwise
@@ -238,9 +245,7 @@ string title, {{NotificationOptions}} dictionary op
If options["{{NotificationOptions/timestamp}}"] exists, then set
notification's timestamp to the value. Otherwise, set
- notification's timestamp to the number of milliseconds from the
- Unix epoch to settings's
- current wall time, rounded to the nearest integer.
+ notification's timestamp to fallbackTimestamp.
Set notification's renotify preference to
options["{{NotificationOptions/renotify}}"].
@@ -276,6 +281,7 @@ string title, {{NotificationOptions}} dictionary op
Return notification.
The
new Notification(title, options)
constructor steps are:
@@ -700,8 +707,15 @@ constructor steps are:
If this's relevant global object is a {{ServiceWorkerGlobalScope}} object, then throw a {{TypeError}}. -
Let notification be the result of creating a notification given - title, options, and this's relevant settings object. +
If options["{{NotificationOptions/actions}}"] is not empty, then + throw a {{TypeError}}. + +
Actions are only supported for persistent notifications. + +
Let notification be the result of + creating a notification with a settings object given title, options, + and this's relevant settings object.
Associate this with notification. @@ -718,12 +732,15 @@ constructor steps are:
Run the show steps for notification. +
The static permission
getter steps are to
return the result of getting the notifications permission state.
+
If you edit standards please refrain from copying the above. Synchronous permissions are like @@ -740,6 +757,7 @@ return the result of getting the notifications permission state.
The static
requestPermission(deprecatedCallback)
method steps are:
@@ -770,6 +788,7 @@ method steps are:
Return promise. +
Notifications are the one instance thus far where asking the end user upfront makes sense. Specifications for other APIs should not use this pattern and instead employ one of the @@ -1029,7 +1048,9 @@ partial interface ServiceWorkerGlobalScope { }; -
The showNotification(title, options)
+
The
+showNotification(title, options)
method steps are:
Let serviceWorkerRegistration be this. +
Let notification be the result of + creating a notification with a settings object given title, options, + and this's relevant settings object. If this threw an exception, then + reject promise with that exception and return promise. -
Let notification be the result of creating a notification given - title, options, this's relevant settings object, and - serviceWorkerRegistration. If this threw an exception, then reject - promise with that exception and return promise. +
Set notification's service worker registration to + this.
Run these steps in parallel: @@ -1068,7 +1090,9 @@ method steps are:
Return promise.
The
getNotifications(filter)
method steps are:
@@ -1116,14 +1140,16 @@ method steps are:
This method returns zero or more new {{Notification}} objects which might represent the same underlying notification of {{Notification}} objects already in existence. +
To fire a service worker notification event named name given -notification (a notification), and an optional action (a DOMString, -defaulting to the empty string), Fire Functional Event name using -{{NotificationEvent}} on notification's -service worker registration with the following properties: +
To fire a service worker notification event named name given a +notification notification, and an optional string action (default +the empty string): run Fire Functional Event given name, {{NotificationEvent}}, +notification's service worker registration, and the following +initialization:
The {{NotificationEvent/notification}} getter steps are to return the value it was initialized -to. +
The notification
getter steps are to
+return the value it was initialized to.
+
The {{NotificationEvent/action}} getter steps are to return the value it was initialized to. +
The action
getter steps are to return the
+value it was initialized to.
+
The following is the event handler (and its corresponding event handler event type) that must be supported as attribute by the