diff --git a/notifications.bs b/notifications.bs index 711d3ff..14484a9 100644 --- a/notifications.bs +++ b/notifications.bs @@ -108,19 +108,42 @@ the notification, but then it should have less visual priority than the is not otherwise accessible to the end user, especially since notification platforms that do not support these features might ignore them. -
A notification has an associated list of -zero or more actions. Each -action has an associated -title and name and -can have an associated icon URL and -icon resource. Users may activate actions, as alternatives to -activating the notification itself. The user agent must determine the -maximum number of actions supported, within the constraints of the -notification platform. +
A notification has an action list (a list of +actions). It is initially empty. + +
An action defines a way the user can interact with a +notification, as an alternative to activing the notification itself. + +
An action has a type, that is "button
" or
+ "text
".
+
+
Actions of type "button
" can only be activated, whereas actions of type
+ "text
" allow the user to input text during activation.
+
+
An action has a title (a string). + +
An action has a name (a string). + +
An action has an icon URL (null or a URL). Unless + stated otherwise, it is null. + +
An action has an icon resource (null or an image). Unless + stated otherwise, it is null. + +
An action has a placeholder (a string). Unless stated + otherwise, it is the empty string. +
The user agent must determine the maximum number of actions supported, within the +constraints of the notification platform.
Since display of actions is platform-dependent, developers are encouraged to make sure that any action a user can invoke from a notification is -also available within the web application. +also available within the web application. The ability to reply inline to +notifications during activation is also platform-dependent, so developers are encouraged to +handle the case where a text action was activated but the reply was null (e.g., by focusing a chat +window).
Some platforms might modify an icon resource to better match the platform's visual style before displaying it to the user, for example by rounding the @@ -152,11 +175,11 @@ these steps: notification's service worker registration to serviceWorkerRegistration. -
If a serviceWorkerRegistration was not provided and
- options's actions
is not empty, throw a
- TypeError
exception.
+
If a serviceWorkerRegistration was not provided and options's
+ actions
is not empty, then throw a {{TypeError}}.
-
Actions are only currently supported for +
Actions are only currently supported for persistent notifications.
If options's silent
is true and options's
@@ -227,27 +250,29 @@ these steps:
If options's requireInteraction
is true, set
notification's require interaction preference flag.
-
Set notification's list of actions to an empty list,
- then for each entry in options's actions
,
- up to the maximum number of actions supported (skip any excess
- entries), perform the following steps:
+
For each entry in options's actions
:
Let action be a new action. +
If the maximum number of actions has already been added, then break. + +
Let action be a new action. -
Set action's name to the entry's
- action
.
+
Set action's type to entry's type
+ member.
-
Set action's title to the
- entry's title
.
+
Set action's name to entry's action
.
-
If entry's icon
is present,
- parse it using baseURL, and if that does
- not return failure, set action's icon URL to the
- return value. (Otherwise icon URL is not set.)
+
Set action's title to entry's title
.
-
Append action to notification's list of - actions. +
If entry's icon
is present, parse it using
+ baseURL, and if that does not return failure, set action's
+ icon URL to the return value.
+
+
If entry's placeholder
is present, then set action's
+ placeholder to the entry's placeholder
.
+
+
Append action to notification's action list.
Return notification. @@ -418,8 +443,8 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!
If the notification platform supports actions and action icons, then for each action - in notification's list of actions fetch action's - icon URL, if icon URL is set. + in notification's action list: fetch + action's icon URL, if icon URL is set.
The intent is to fetch this resource similar to an
<img>
,
@@ -495,6 +520,9 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!
notification platform API).
+
If the platform does not support entering text within a notification, implementers + are expected to present text actions as button actions. +
If shown is false or oldNotification is non-null and notification's renotify preference flag has been set, then run the alert steps for notification. @@ -504,6 +532,10 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[! notification. +
User agents are required to attribute notifications to the origin they +are associated with. This reduces the possibility of phishing attacks where a notification has been +designed to look like it originates from another origin. The user should be aware that data entered +into the notification will be made available to the attributed origin.
Let action be the empty string. +
Let reply be null. +
If one of notification's actions was activated by the user, then set action to that action's name. +
If one of notification's actions
+ with type text
was activated by the user, and the opportunity to
+ input a reply was provided, then set reply to the text entered by
+ the user during activation.
+
Let callback be an algorithm that when invoked with a global,
fires a service worker notification event
- named notificationclick
given notification and action on
- global.
+ named notificationclick
given notification, action and
+ reply on global.
Then run Handle Functional Event with notification's service worker registration and callback. @@ -578,7 +617,8 @@ must be run.
Let callback be an algorithm that when invoked with a global,
fires a service worker notification event
- named notificationclose
given notification on global.
+ named notificationclose
given notification, action
+ set to the empty string and reply set to null on global.
Then run Handle Functional Event with notification's
service worker registration and callback.
@@ -666,9 +706,16 @@ enum NotificationDirection {
};
dictionary NotificationAction {
+ NotificationActionType type = "button";
required DOMString action;
required DOMString title;
USVString icon;
+ DOMString? placeholder = "";
+};
+
+enum NotificationActionType {
+ "button",
+ "text"
};
callback NotificationPermissionCallback = void (NotificationPermission permission);
@@ -861,35 +908,41 @@ return the notification's require interaction prefere
result of the following steps:
Let frozenActions be an empty list of type {{NotificationAction}}.
+ Let frozenActions be an empty list of type {{NotificationAction}}.
- For each entry in the notification's list of
- actions, perform the following steps:
+ For each entry in notification's action list:
Let action be a new {{NotificationAction}}.
+ Let action be a new {{NotificationAction}}.
+
+ Set action's {{NotificationAction/type}} to entry's
+ type.
+
+ Set action's {{NotificationAction/action}} to entry's
+ name.
- Set action's {{NotificationAction/action}} to
- entry's name.
+ Set action's {{NotificationAction/title}} to entry's
+ title.
- Set action's {{NotificationAction/title}} to
- entry's title.
+ Set action's {{NotificationAction/icon}} to entry's
+ icon URL.
- Set action's {{NotificationAction/icon}} to
- entry's icon URL.
+ Set action's {{NotificationAction/placeholder}} to entry's
+ placeholder.
-
- Call Object.freeze on action, to
- prevent accidental mutation by scripts.
+
+ Call Object.freeze on action, to prevent accidental mutation
+ by scripts.
- Append action to frozenActions.
+ Append action to frozenActions.
Create a frozen array from frozenActions.
+ Create a frozen array from frozenActions.
-
-
- Examples
@@ -1000,11 +1053,13 @@ partial interface ServiceWorkerRegistration {
interface NotificationEvent : ExtendableEvent {
readonly attribute Notification notification;
readonly attribute DOMString action;
+ readonly attribute DOMString? reply;
};
dictionary NotificationEventInit : ExtendableEventInit {
required Notification notification;
DOMString action = "";
+ DOMString? reply = null;
};
partial interface ServiceWorkerGlobalScope {
@@ -1084,11 +1139,13 @@ the same underlying notification of {{Notification}} objects already in e
To fire a service worker notification event named e -given notification and action, +given notification, action and reply, fire an event named e, using {{NotificationEvent}}, with the {{NotificationEvent/notification}} attribute initialized to a new -{{Notification}} object representing notification and the -{{NotificationEvent/action}} attribute initialized to action. +{{Notification}} object representing notification, the +{{NotificationEvent/action}} attribute initialized to action, and the +{{NotificationEvent/reply}} attribute initialized to reply. +
The {{NotificationEvent/notification}} attribute's getter must return the @@ -1097,6 +1154,9 @@ value it was initialized to.
The {{NotificationEvent/action}} attribute's getter must return the value it was initialized to. +
The {{NotificationEvent/reply}} attribute's getter must 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 {{ServiceWorkerGlobalScope}} object: @@ -1122,6 +1182,7 @@ was initialized to. Addison Phillips, Aharon (Vladimir) Lanin, Alex Russell, +Anita Woodruff, Anssi Kostiainen, Arkadiusz Michalski, Boris Zbarsky,