diff --git a/notifications.bs b/notifications.bs index 36bc8f5..a0c463f 100644 --- a/notifications.bs +++ b/notifications.bs @@ -60,6 +60,9 @@ or "rtl").

A notification has an associated body (a string). +

A notification has an associated navigation URL +(null or a URL). It is initially null. +

A notification has an associated tag (a string).

A notification has an associated data (a @@ -137,6 +140,9 @@ support these features might ignore them.

title
A string. +
navigation URL +
Null or a URL. It is initially null. +
icon URL
Null or a URL. It is initially null. @@ -220,6 +226,11 @@ important information through, e.g., loss of color or clipped corners.
  • Set notification's body to options["{{NotificationOptions/body}}"]. +

  • If options["{{NotificationOptions/navigate}}"] exists, then + parse it using baseURL, and if that does not return failure, set + notification's navigation URL to the return value. (Otherwise + notification's navigation URL remains null.) +

  • Set notification's tag to options["{{NotificationOptions/tag}}"]. @@ -270,6 +281,11 @@ important information through, e.g., loss of color or clipped corners.

  • Set action's title to entry["{{NotificationAction/title}}"]. +

  • If entry["{{NotificationAction/navigate}}"] exists, then + parse it using baseURL, and if that does not return failure, + set action's navigation URL to the return value. + (Otherwise action's navigation URL remains null.) +

  • If entry["{{NotificationAction/icon}}"] exists, then parse it using baseURL, and if that does not return failure, set action's icon URL to the return value. (Otherwise @@ -541,18 +557,51 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[! platform supports activation, the user agent must (unless otherwise specified) run these steps:

      +
    1. Let action be null. + +

    2. If one of notification's actions was activated by the end + user, then set action to that notification action. + +

    3. Let navigationURL be notification's + navigation URL. + +

    4. +

      If action is non-null, then set navigationURL to action's + navigation URL. + +

      This intentionally makes it so that when a notification action's + navigation URL is null, it falls through to the + click event, providing more flexibility to the web developer. + +

    5. +

      If navigationURL is non-null: + +

        +
      1. If there is an existing top-level traversable traversable within + the user agent's top-level traversable set whose + active document's URL equals + navigationURL with exclude fragments set to true, then + navigate traversable to navigationURL and return. If there are + multiple top-level traversables that satisfy the condition the user agent has to + pick one in an implementation-defined manner. + + +

      2. Create a fresh top-level traversable given navigationURL. + +

      3. Return. +

      +
    6. If notification is a persistent notification, then:

        -
      1. Let action be the empty string. +

      2. Let actionName be the empty string. -

      3. If one of notification's actions was activated by the - user, then set action to that notification action's +

      4. If action is non-null, then set actionName to action's name.

      5. Fire a service worker notification event named "notificationclick" given - notification and action. + notification and actionName.
    7. @@ -643,6 +692,7 @@ interface Notification : EventTarget { readonly attribute NotificationDirection dir; readonly attribute DOMString lang; readonly attribute DOMString body; + readonly attribute USVString navigate; readonly attribute DOMString tag; readonly attribute USVString image; readonly attribute USVString icon; @@ -662,6 +712,7 @@ dictionary NotificationOptions { NotificationDirection dir = "auto"; DOMString lang = ""; DOMString body = ""; + USVString navigate; DOMString tag = ""; USVString image; USVString icon; @@ -690,6 +741,7 @@ enum NotificationDirection { dictionary NotificationAction { required DOMString action; required DOMString title; + USVString navigate; USVString icon; }; @@ -853,6 +905,16 @@ return the maximum number of actions supported.

      The body getter steps are to return this's notification's body. +

      The navigate getter steps are: + +

        +
      1. If this's notification's navigation URL is null, then + return the empty string. + +

      2. Return this's notification's navigation URL, + serialized. +

      +

      The tag getter steps are to return this's notification's tag. @@ -925,6 +987,10 @@ then return null.

    8. Set action["{{NotificationAction/title}}"] to entry's title. +

    9. If entry's navigation URL is non-null, then + set action["{{NotificationAction/navigate}}"] to entry's + navigation URL, serialized. +

    10. If entry's icon URL is non-null, then set action["{{NotificationAction/icon}}"] to entry's icon URL, serialized.