From e07fd93fb9240f71ac6721c7aa8ffc10b79278d1 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 18 Nov 2021 20:48:48 -0500 Subject: [PATCH 01/10] Remove Permission model section. --- notifications.bs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/notifications.bs b/notifications.bs index 5686bd6..60f572d 100644 --- a/notifications.bs +++ b/notifications.bs @@ -291,32 +291,6 @@ removed from the list of notifications. "notification center" (if available). -

Permission model

- -

Notifications can only be displayed if the -user (or user agent on behalf of the user) has granted permission. -The permission to show notifications -for a given origin is one of three strings: - -

-
"default" -

This is equivalent to "denied", but the user has made no - explicit choice thus far. - -

"denied" -

This means the user does not want - notifications. - -

"granted" -

This means notifications can be - displayed. -

- -

There is no equivalent to "default" -meaning "granted". In that case -"granted" is simply returned as there would be no reason -for the application to ask for permission. -

Permissions integration

The Notifications API is a powerful feature which is identified by the string From 51aff35a4198d645d02fe778ade3019c0ad0832c Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 19 Nov 2021 09:30:24 -0500 Subject: [PATCH 02/10] Add get the notifications permission state. Conveniently, this handles the secure context check for us, via get the current permissions state. --- notifications.bs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/notifications.bs b/notifications.bs index 60f572d..4530f33 100644 --- a/notifications.bs +++ b/notifications.bs @@ -297,6 +297,17 @@ removed from the list of notifications. "notifications" and has its allowed in non-secure contexts flag set. [[!Permissions]] +

To get the notifications permission state, run these steps: + +

    +
  1. Let permissionState be the result of getting the current permission state + with "notifications". + +

  2. If permissionState is "prompt", then return "default". + +

  3. Return permissionState. +

+

This specification's "default" permission state maps to the [=permission/prompt=] permission state in the Permissions API. From daefe12714ed565e99be3034abb8046b5e8bdf05 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 19 Nov 2021 09:51:17 -0500 Subject: [PATCH 03/10] Update constructor to use getting the notifications permission state --- notifications.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notifications.bs b/notifications.bs index 4530f33..cdbd8bb 100644 --- a/notifications.bs +++ b/notifications.bs @@ -706,9 +706,9 @@ constructor steps are:

Run these steps in parallel:

    -
  1. If permission for notification's origin is not - "granted", then queue a task to fire an event named error - on this, and abort these steps. +

  2. If the result of getting the notifications permission state is not + "granted", then queue a task to fire an event named + error on this, and abort these steps.

  3. Run the fetch steps for notification. From 2e61c6245421c77bc42552647e6ff38b649523b6 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 19 Nov 2021 09:55:54 -0500 Subject: [PATCH 04/10] Update SW API to use getting the notifications permission state --- notifications.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications.bs b/notifications.bs index cdbd8bb..7ebe196 100644 --- a/notifications.bs +++ b/notifications.bs @@ -1068,7 +1068,7 @@ method steps are:

    Run these steps in parallel:

      -
    1. If permission for notification's origin is not +

    2. If the result of getting the notifications permission state is not "granted", then queue a global task on the DOM manipulation task source given global to reject promise with a {{TypeError}}, and abort these steps. From f3cdc87915e049a872adc9062d10a29eb3e28991 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 19 Nov 2021 10:04:25 -0500 Subject: [PATCH 05/10] Update static getters to use getting the notifications permission state --- notifications.bs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/notifications.bs b/notifications.bs index 7ebe196..d731d70 100644 --- a/notifications.bs +++ b/notifications.bs @@ -720,8 +720,7 @@ constructor steps are:

      Static members

      The static permission getter steps are to -return the permission for the current settings object's -origin. +return the result of getting the notifications permission state.

      If you edit standards please refrain from copying the above. Synchronous permissions are like @@ -745,27 +744,14 @@ method steps are:

      1. Let global be the current global object. -

      2. Let permissionDescriptor be the {{PermissionDescriptor}} with - {{PermissionDescriptor/name}} set to "notifications". - -

      3. Let permissionStatus be the result of - creating a `PermissionStatus` for - permissionDescriptor. -

      4. Let promise be a new promise in this's relevant Realm.

      5. Run these steps in parallel:

          -
        1. Run the permission query algorithm with - permissionDescriptor and permissionStatus. - -

        2. Let permissionState be permissionStatus's - {{PermissionStatus/state}}. - -

        3. If permissionState is {{PermissionState/"prompt"}}, then set - permissionState to "default". +

        4. Let permissionState be the result of + getting the notifications permission state.

        5. Queue a global task on the DOM manipulation task source given global From 78937c46c8a8cce3aed1c3976cc070f264c453f1 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 19 Nov 2021 10:09:09 -0500 Subject: [PATCH 06/10] Restrict Notifications to secure contexts. --- notifications.bs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/notifications.bs b/notifications.bs index d731d70..f34eabc 100644 --- a/notifications.bs +++ b/notifications.bs @@ -293,9 +293,8 @@ removed from the list of notifications.

          Permissions integration

          -

          The Notifications API is a powerful feature which is identified by the string -"notifications" and has its allowed in non-secure contexts flag set. -[[!Permissions]] +

          The Notifications API is a powerful feature which is identified by the name "notifications". [[!Permissions]]

          To get the notifications permission state, run these steps: From bbedb832047c5b03b885ce0af362561848699874 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 22 Nov 2021 10:56:50 -0500 Subject: [PATCH 07/10] Apply @annevk's suggestions. Co-authored-by: Anne van Kesteren --- notifications.bs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/notifications.bs b/notifications.bs index f34eabc..a05ca07 100644 --- a/notifications.bs +++ b/notifications.bs @@ -293,23 +293,20 @@ removed from the list of notifications.

          Permissions integration

          -

          The Notifications API is a powerful feature which is identified by the name "notifications". [[!Permissions]] +

          The Notifications API is a powerful feature which is identified by the +name "`notifications`". [[!Permissions]]

          To get the notifications permission state, run these steps:

          1. Let permissionState be the result of getting the current permission state - with "notifications". + with "`notifications`".

          2. If permissionState is "prompt", then return "default".

          3. Return permissionState.

          -

          This specification's "default" permission -state maps to the [=permission/prompt=] permission state in the Permissions API. -

          Direction

          From 090b8e37148d1f6caf0d73ca064077bfbf004778 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 22 Nov 2021 11:11:30 -0500 Subject: [PATCH 08/10] Stray whitespace cleanup (thx GitHub) --- notifications.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications.bs b/notifications.bs index a05ca07..6075fda 100644 --- a/notifications.bs +++ b/notifications.bs @@ -293,7 +293,7 @@ removed from the list of notifications.

          Permissions integration

          -

          The Notifications API is a powerful feature which is identified by the +

          The Notifications API is a powerful feature which is identified by the name "`notifications`". [[!Permissions]]

          To get the notifications permission state, run these steps: From 9571a2d1728508872eb7ea717f060ce0b27ba519 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 22 Nov 2021 12:37:04 -0500 Subject: [PATCH 09/10] Notifications.requestPermssion should request permission to use "notifications" --- notifications.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notifications.bs b/notifications.bs index 6075fda..5798228 100644 --- a/notifications.bs +++ b/notifications.bs @@ -294,13 +294,13 @@ removed from the list of notifications.

          Permissions integration

          The Notifications API is a powerful feature which is identified by the -name "`notifications`". [[!Permissions]] +name "notifications". [[!Permissions]]

          To get the notifications permission state, run these steps:

          1. Let permissionState be the result of getting the current permission state - with "`notifications`". + with "notifications".

          2. If permissionState is "prompt", then return "default". @@ -747,7 +747,7 @@ method steps are:

            1. Let permissionState be the result of - getting the notifications permission state. + requesting permission to use {{PermissionName/notifications}}.

            2. Queue a global task on the DOM manipulation task source given global From 4eff82257ee618dc880b5911148dcd7b2a1ac5e2 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 22 Nov 2021 14:56:58 -0500 Subject: [PATCH 10/10] Another round o' Anne's suggested tweaks. Co-authored-by: Anne van Kesteren --- notifications.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notifications.bs b/notifications.bs index 5798228..43ec345 100644 --- a/notifications.bs +++ b/notifications.bs @@ -294,13 +294,13 @@ removed from the list of notifications.

              Permissions integration

              The Notifications API is a powerful feature which is identified by the -name "notifications". [[!Permissions]] +name "{{PermissionName/notifications}}". [[!Permissions]]

              To get the notifications permission state, run these steps:

              1. Let permissionState be the result of getting the current permission state - with "notifications". + with "{{PermissionName/notifications}}".

              2. If permissionState is "prompt", then return "default". @@ -747,7 +747,7 @@ method steps are:

                1. Let permissionState be the result of - requesting permission to use {{PermissionName/notifications}}. + requesting permission to use "{{PermissionName/notifications}}".

                2. Queue a global task on the DOM manipulation task source given global