From 904bcad2b52137236cda15218586bfa45465887e Mon Sep 17 00:00:00 2001 From: Anita Woodruff Date: Tue, 22 May 2018 11:57:28 +0100 Subject: [PATCH 01/10] Adding Inline Notification Replies to the spec --- notifications.bs | 102 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 20 deletions(-) diff --git a/notifications.bs b/notifications.bs index 711d3ff..4c0d139 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 actions, +a list of notification actions, initially empty. + +

A notification action defines a way the user can interact with +a notification, as an alternative to activing the notification itself. + +

+

A notification 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. + +

A notification action has a title (a DOMString). + +

A notification action has a name (a DOMString). + +

A notification action has an icon URL (null + or a URL). Unless stated otherwise, it is null. + +

A notification action has an icon resource + (null or an image). Unless stated otherwise, it is null. + +

A notification action has a placeholder + (a DOMString). Unless stated otherwise, it is an 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 @@ -227,14 +250,22 @@ 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:
      +
    1. If the user agent does not support additional actions, break. +
    2. Let action be a new action. +

    3. Set action's type to the entry's + type property. + +

    4. If the user agent does not support additional actions of this + type, continue. + +

      For instance, some operating systems don't support buttons if a text action has + been provided, or vice-versa. +

    5. Set action's name to the entry's action. @@ -244,7 +275,11 @@ these steps:

    6. 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.) + return value. + +

    7. If entry's placeholder is present, set + action's placeholder to the entry's + placeholder.

    8. Append action to notification's list of actions. @@ -517,11 +552,18 @@ specified) run these steps:

      If notification is a persistent notification, then:

        -
      1. Let action be the empty string. +

      2. Let action be an empty string. + +

      3. Let reply be null.

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

      5. 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. +

      6. Let callback be an algorithm that when invoked with a global, fires a service worker notification event named notificationclick given notification and action on @@ -666,9 +708,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); @@ -863,12 +912,14 @@ result of the following steps:

        1. Let frozenActions be an empty list of type {{NotificationAction}}. -

        2. For each entry in the notification's list of - actions, perform the following steps: +

        3. For each entry in notification's actions:

          1. Let action be a new {{NotificationAction}}. +

          2. Set action's {{NotificationAction/type}} to + entry's type. +

          3. Set action's {{NotificationAction/action}} to entry's name. @@ -878,6 +929,9 @@ result of the following steps:

          4. Set action's {{NotificationAction/icon}} to entry's icon URL. +

          5. Set action's {{NotificationAction/placeholder}} to + entry's placeholder. +

            The {{NotificationEvent/notification}} attribute's getter must return the @@ -1097,6 +1155,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 +1183,7 @@ was initialized to. Addison Phillips, Aharon (Vladimir) Lanin, Alex Russell, +Anita Woodruff, Anssi Kostiainen, Arkadiusz Michalski, Boris Zbarsky, From eac4ebe6da29464dd82dbff51cae123b13fc0cf8 Mon Sep 17 00:00:00 2001 From: Anita Woodruff Date: Thu, 24 May 2018 15:53:20 +0100 Subject: [PATCH 02/10] Updating based on annevk's review --- notifications.bs | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/notifications.bs b/notifications.bs index 4c0d139..8e0e9af 100644 --- a/notifications.bs +++ b/notifications.bs @@ -108,31 +108,31 @@ 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 actions, -a list of notification actions, initially empty. +

            A notification has an action list (a list of +actions). It is initially empty.

            A notification action defines a way the user can interact with a notification, as an alternative to activing the notification itself.

            -

            A notification 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. +

            A notification action has a type, that is "button" or + "text". -

            A notification action has a title (a DOMString). +

            Actions of type "button" can only be activated, whereas actions of type + "text" allow the user to input text during activation. -

            A notification action has a name (a DOMString). +

            A notification action has a title (a string). -

            A notification action has an icon URL (null - or a URL). Unless stated otherwise, it is null. +

            A notification action has a name (a string). -

            A notification action has an icon resource - (null or an image). Unless stated otherwise, it is null. +

            A notification action has an icon URL (null or a URL). Unless stated + otherwise, it is null. -

            A notification action has a placeholder - (a DOMString). Unless stated otherwise, it is an empty string. +

            A notification action has an icon resource (null or an image). Unless stated + otherwise, it is null. + +

            A notification action has a placeholder (a string). Unless stated otherwise, + it is an empty string.

            The user agent must determine the maximum number of actions supported, within the @@ -142,8 +142,8 @@ constraints of the notification platform. encouraged to make sure that any action a user can invoke from a notification is 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). +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 @@ -250,18 +250,18 @@ these steps:

          6. If options's requireInteraction is true, set notification's require interaction preference flag. -

          7. For each entry in options's actions: +
          8. For each entry in options's actions:

              -
            1. If the user agent does not support additional actions, break. +
            2. If the user agent does not support additional actions, then break.

            3. Let action be a new action.

            4. Set action's type to the entry's type property. -

            5. If the user agent does not support additional actions of this - type, continue. +
            6. If the user agent does not support additional actions of this + type, then continue.

              For instance, some operating systems don't support buttons if a text action has been provided, or vice-versa. @@ -560,14 +560,14 @@ specified) run these steps: user, then set action to that action's name.

            7. If one of notification's actions - with type 'text' was activated by the user, and the opportunity to + 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.

            8. 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.

            9. Then run Handle Functional Event with notification's service worker registration and callback. @@ -1140,7 +1140,7 @@ 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, the From 844b530d36de5dea51d21b9dd15b2e8713849893 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 28 May 2018 14:25:20 +0200 Subject: [PATCH 03/10] address some nits --- notifications.bs | 122 +++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 62 deletions(-) diff --git a/notifications.bs b/notifications.bs index 8e0e9af..f04f0cf 100644 --- a/notifications.bs +++ b/notifications.bs @@ -108,31 +108,31 @@ 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 action list (a list of -actions). It is initially empty. +

              A notification has an action list (a list of +actions). It is initially empty. -

              A notification action defines a way the user can interact with -a notification, as an alternative to activing the notification itself. +

              An action defines a way the user can interact with a +notification, as an alternative to activing the notification itself. -

              -

              A notification action has a type, that is "button" or +

              +

              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. -

              A notification action has a title (a string). +

              A action has a title (a string). -

              A notification action has a name (a string). +

              A action has a name (a string). -

              A notification action has an icon URL (null or a URL). Unless stated - otherwise, it is null. +

              A action has an icon URL (null or a URL). Unless + stated otherwise, it is null. -

              A notification action has an icon resource (null or an image). Unless stated - otherwise, it is null. +

              A action has an icon resource (null or an image). Unless + stated otherwise, it is null. -

              A notification action has a placeholder (a string). Unless stated otherwise, - it is an empty string. +

              A action has a placeholder (a string). Unless stated + otherwise, it is an empty string.

              The user agent must determine the maximum number of actions supported, within the @@ -175,11 +175,11 @@ these steps: notification's service worker registration to serviceWorkerRegistration. -

            10. If a serviceWorkerRegistration was not provided and - options's actions is not empty, throw a - TypeError exception. +

            11. +

              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.

            12. If options's silent is true and options's @@ -250,39 +250,36 @@ these steps:

            13. If options's requireInteraction is true, set notification's require interaction preference flag. -

            14. For each entry in options's actions: +

            15. +

              For each entry in options's actions:

                -
              1. If the user agent does not support additional actions, then break. +

              2. If the user agent does not support additional actions, then break. -

              3. Let action be a new action. +

              4. Let action be a new action. -

              5. Set action's type to the entry's - type property. +

              6. Set action's type to entry's type + member. -

              7. If the user agent does not support additional actions of this - type, then continue. +

              8. +

                If the user agent does not support additional actions of this type, then + continue.

                For instance, some operating systems don't support buttons if a text action has been provided, or vice-versa. -

              9. Set action's name to the entry's - action. +

              10. Set action's name to entry's action. -

              11. Set action's title to the - entry's title. +

              12. Set action's title to entry's title. -

              13. 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. +

              14. 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. -

              15. If entry's placeholder is present, set - action's placeholder to the entry's - placeholder. +

              16. If entry's placeholder is present, then set action's + placeholder to the entry's placeholder. -

              17. Append action to notification's list of - actions. +

              18. Append action to notification's action list.

            16. Return notification. @@ -453,8 +450,8 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!

            17. 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>, @@ -910,40 +907,41 @@ return the notification's require interaction prefere result of the following steps:

                -
              1. Let frozenActions be an empty list of type {{NotificationAction}}. +

              2. Let frozenActions be an empty list of type {{NotificationAction}}. -

              3. For each entry in notification's actions: +

              4. +

                For each entry in notification's action list:

                  -
                1. Let action be a new {{NotificationAction}}. +

                2. Let action be a new {{NotificationAction}}. -

                3. Set action's {{NotificationAction/type}} to - entry's type. +

                4. Set action's {{NotificationAction/type}} to entry's + type. -

                5. Set action's {{NotificationAction/action}} to - entry's name. +

                6. Set action's {{NotificationAction/action}} to entry's + name. -

                7. Set action's {{NotificationAction/title}} to - entry's title. +

                8. Set action's {{NotificationAction/title}} to entry's + title. -

                9. Set action's {{NotificationAction/icon}} to - entry's icon URL. +

                10. Set action's {{NotificationAction/icon}} to entry's + icon URL. -

                11. Set action's {{NotificationAction/placeholder}} to - entry's placeholder. +

                12. Set action's {{NotificationAction/placeholder}} to entry's + placeholder. - -

                13. Call Object.freeze on action, to - prevent accidental mutation by scripts. + +

                14. Call Object.freeze on action, to prevent accidental mutation + by scripts. -

                15. Append action to frozenActions. +

                16. Append action to frozenActions.

                -
              5. Create a frozen array from frozenActions. +

              6. Create a frozen array from frozenActions.

              Examples

              From 1dba6470001d45a3998e7d28205cd045d29d43f7 Mon Sep 17 00:00:00 2001 From: Anita Woodruff Date: Tue, 29 May 2018 14:30:11 +0100 Subject: [PATCH 04/10] s/A action/An action --- notifications.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/notifications.bs b/notifications.bs index f04f0cf..9c7b192 100644 --- a/notifications.bs +++ b/notifications.bs @@ -121,17 +121,17 @@ notification, as an alternative to activing the notification itself.

              Actions of type "button" can only be activated, whereas actions of type "text" allow the user to input text during activation. -

              A action has a title (a string). +

              An action has a title (a string). -

              A action has a name (a string). +

              An action has a name (a string). -

              A action has an icon URL (null or a URL). Unless +

              An action has an icon URL (null or a URL). Unless stated otherwise, it is null. -

              A action has an icon resource (null or an image). Unless +

              An action has an icon resource (null or an image). Unless stated otherwise, it is null. -

              A action has a placeholder (a string). Unless stated +

              An action has a placeholder (a string). Unless stated otherwise, it is an empty string. From e308162bbce0e77eec2c6597134e0442140a027a Mon Sep 17 00:00:00 2001 From: Anita Woodruff Date: Thu, 31 May 2018 16:57:16 +0100 Subject: [PATCH 05/10] Addressing (some of) Peter's comments --- notifications.bs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/notifications.bs b/notifications.bs index 9c7b192..60414d8 100644 --- a/notifications.bs +++ b/notifications.bs @@ -132,7 +132,7 @@ notification, as an alternative to activing the notification itself. stated otherwise, it is null.

              An action has a placeholder (a string). Unless stated - otherwise, it is an empty string. + otherwise, it is the empty string.

              The user agent must determine the maximum number of actions supported, within the @@ -254,20 +254,13 @@ these steps:

              For each entry in options's actions:

                -
              1. If the user agent does not support additional actions, then break. +

              2. If the maximum number of actions has already been added, then break.

              3. Let action be a new action.

              4. Set action's type to entry's type member. -

              5. -

                If the user agent does not support additional actions of this type, then - continue. - -

                For instance, some operating systems don't support buttons if a text action has - been provided, or vice-versa. -

              6. Set action's name to entry's action.

              7. Set action's title to entry's title. @@ -527,6 +520,10 @@ 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 treat text actions as regular buttons and update their type to button + accordingly. +

            18. 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. @@ -549,7 +546,7 @@ specified) run these steps:

              If notification is a persistent notification, then:

                -
              1. Let action be an empty string. +

              2. Let action be the empty string.

              3. Let reply be null. From 846705902634bf1c2401c802cf748d19e9aa3d45 Mon Sep 17 00:00:00 2001 From: Anita Woodruff Date: Wed, 6 Jun 2018 12:18:42 +0100 Subject: [PATCH 06/10] Update algorithm in 'Closing a notification' to pass action and reply --- notifications.bs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifications.bs b/notifications.bs index 60414d8..95362b4 100644 --- a/notifications.bs +++ b/notifications.bs @@ -614,7 +614,8 @@ must be run.

                1. 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.

                2. Then run Handle Functional Event with notification's service worker registration and callback. From 56bb9a1cfa4616f8405432749e1d4826eb23a4d9 Mon Sep 17 00:00:00 2001 From: Anita Woodruff Date: Fri, 22 Jun 2018 19:01:56 +0000 Subject: [PATCH 07/10] Add a note encouraging attribution --- notifications.bs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/notifications.bs b/notifications.bs index 95362b4..d002589 100644 --- a/notifications.bs +++ b/notifications.bs @@ -533,6 +533,9 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[! notification.

                +

                User agents are strongly encouraged 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.

                Activating a notification

                From b8426e90d6eb1c44a26767606d35830a5c8d42fc Mon Sep 17 00:00:00 2001 From: anitawoodruff Date: Tue, 10 Jul 2018 14:58:13 +0100 Subject: [PATCH 08/10] Change note to mandate attribution --- notifications.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications.bs b/notifications.bs index d002589..a256ccf 100644 --- a/notifications.bs +++ b/notifications.bs @@ -533,7 +533,7 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[! notification.
              -

              User agents are strongly encouraged to attribute notifications to the origin they +

              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. From 301ccf846484f945b70ae94e70c6e0bae8a3faf7 Mon Sep 17 00:00:00 2001 From: anitawoodruff <1918555+anitawoodruff@users.noreply.github.com> Date: Fri, 13 Jul 2018 10:39:31 +0100 Subject: [PATCH 09/10] Amend note on treating text actions as buttons Text actions should be treated as button actions for display purposes only - their type should not be updated. --- notifications.bs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/notifications.bs b/notifications.bs index a256ccf..f7e4a4b 100644 --- a/notifications.bs +++ b/notifications.bs @@ -521,8 +521,7 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!

            If the platform does not support entering text within a notification, implementers - are expected to treat text actions as regular buttons and update their type to button - accordingly. + are expected to present text actions as button actions.

          9. If shown is false or oldNotification is non-null and notification's renotify preference flag has been set, then run From 713eafb12549ead12af270891dd6b080ad405e58 Mon Sep 17 00:00:00 2001 From: anitawoodruff <1918555+anitawoodruff@users.noreply.github.com> Date: Wed, 18 Jul 2018 11:05:24 +0100 Subject: [PATCH 10/10] Add note on destination of reply data In response to TAG Review, emphasize that user agents should make it clear that replies entered in a notification will be sent to the notification's origin. --- notifications.bs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifications.bs b/notifications.bs index f7e4a4b..14484a9 100644 --- a/notifications.bs +++ b/notifications.bs @@ -534,7 +534,8 @@ interpreted as a language tag. Validity or well-formedness are not enforced. [[!

            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. +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.

            Activating a notification