From a41a04033e41376a030ffc248bf286305f001190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 29 Jun 2021 15:52:10 +1000 Subject: [PATCH 1/5] Handle not fully active documents when querying Permissions API --- index.bs | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/index.bs b/index.bs index 6acd2cb..0f1addb 100644 --- a/index.bs +++ b/index.bs @@ -503,6 +503,7 @@ spec:webidl; type:interface; text:Promise Promise<PermissionStatus> query(object permissionDesc); }; +<<<<<<< HEAD

`query()` method

@@ -544,6 +545,54 @@ spec:webidl; type:interface; text:Promise found in the Examples section.

+======= +

+ When the query(permissionDesc) method is + invoked, the user agent MUST run the following query a + permission algorithm, passing the parameter + permissionDesc: +

+
    +
  1. Let |doc| be the [=current settings object=]'s [=associated Document=].
  2. +
  3. If |doc| is not [=Document/fully active=], return [=a promise rejected with=] + a "InvalidStateError" {{DOMException}}. +
  4. +
  5. Let |rootDesc| be the object |permissionDesc| refers to, converted to + an IDL value of type {{PermissionDescriptor}}. If this throws an + exception, return a promise rejected with that exception and abort + these steps. +
  6. +
  7. Let |typedDescriptor| be the object |permissionDesc| refers to, + converted to an IDL value of + |rootDesc|.{{PermissionDescriptor/name}}'s permission + descriptor type. If this throws an exception, return a promise + rejected with that exception and abort these steps. +
  8. +
  9. Let promise be a newly-created {{Promise}}. +
  10. +
  11. Return promise and continue the following steps + asynchronously. +
  12. +
  13. Run the steps to create a PermissionStatus for |typedDescriptor|, + and let status be the result. +
  14. +
  15. + Run |status|@{{PermissionStatus/[[query]]}}.{{PermissionDescriptor/name}}'s permission query + algorithm, passing |status|@{{PermissionStatus/[[query]]}} and |status|. +
  16. +
  17. + If |doc| is not longer [=Document/fully active=] when this step is reached, + set |status|.{{PermissionStatus/state}} to {{PermissionState/"denied"}}. +
  18. +
  19. Resolve promise with status. +
  20. +
+
+ If a developer wants to check multiple permissions at once, the editors + recommend the use of {{Promise}}.all(). An example can be + found in the Examples section. +
+>>>>>>> beadff4 (Handle not fully active documents when querying Permissions API)

From 487e1f90ba42022e1e565060944394d681f98fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 29 Jun 2021 16:00:32 +1000 Subject: [PATCH 2/5] remove update to denied... leave it alone --- index.bs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.bs b/index.bs index 0f1addb..fb554c3 100644 --- a/index.bs +++ b/index.bs @@ -580,10 +580,6 @@ spec:webidl; type:interface; text:Promise Run |status|@{{PermissionStatus/[[query]]}}.{{PermissionDescriptor/name}}'s permission query algorithm, passing |status|@{{PermissionStatus/[[query]]}} and |status|. -
  • - If |doc| is not longer [=Document/fully active=] when this step is reached, - set |status|.{{PermissionStatus/state}} to {{PermissionState/"denied"}}. -
  • Resolve promise with status.
  • From 89cb77b6df30be2e335adafcbdfd4ce3d40c9c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 29 Jun 2021 16:04:05 +1000 Subject: [PATCH 3/5] Removed var that's not needed --- index.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index fb554c3..09294ec 100644 --- a/index.bs +++ b/index.bs @@ -553,9 +553,9 @@ spec:webidl; type:interface; text:Promise permissionDesc:

      -
    1. Let |doc| be the [=current settings object=]'s [=associated Document=].
    2. -
    3. If |doc| is not [=Document/fully active=], return [=a promise rejected with=] - a "InvalidStateError" {{DOMException}}. +
    4. If the [=current settings object=]'s [=associated Document=] is not + [=Document/fully active=], return [=a promise rejected with=] a + "InvalidStateError" {{DOMException}}.
    5. Let |rootDesc| be the object |permissionDesc| refers to, converted to an IDL value of type {{PermissionDescriptor}}. If this throws an From 19ed04ba93db5f3e8165eff0e7ec7e58cc7b5f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 29 Jun 2021 16:11:49 +1000 Subject: [PATCH 4/5] Add fully active check when event fires instead --- index.bs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.bs b/index.bs index 09294ec..d67cd92 100644 --- a/index.bs +++ b/index.bs @@ -464,6 +464,12 @@ spec:webidl; type:interface; text:Promise it MUST asynchronously run the following steps:

        +
      1. + Let |document| this |status|'s [=relevant global object=]'s [=associated Document=]. +
      2. +
      3. + If |document| is null or |document| is not [=Document/fully active=], terminate this algorithm. +
      4. Run status@{{PermissionStatus/[[query]]}}.{{PermissionDescriptor/name}}'s permission query algorithm, passing status@{{PermissionStatus/[[query]]}} From 613b42413add043dcbfb69f7e59cfb81be27e38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 26 Jul 2021 18:25:08 +1000 Subject: [PATCH 5/5] handling of fully active --- index.bs | 59 +++++++++++++------------------------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/index.bs b/index.bs index d67cd92..39da61f 100644 --- a/index.bs +++ b/index.bs @@ -197,7 +197,7 @@ spec:webidl; type:interface; text:Promise A |descriptor|'s permission state for an optional environment settings object |settings| is the result of the following algorithm, which returns one of - {{PermissionState/"granted"}}, {{PermissionState/"prompt"}}, or {{PermissionState/"denied"}}: + the {{PermissionState}} enum values or failure:

        1. @@ -213,6 +213,9 @@ spec:webidl; type:interface; text:Promise |descriptor|.{{PermissionDescriptor/name}} and |settings| has an associated `Document` named document, run the following step:
            +
          1. + If |document| is not [=Document/fully active=], return failure. +
          2. If document is not allowed to use the feature identified by |descriptor|.{{PermissionDescriptor/name}} @@ -509,7 +512,6 @@ spec:webidl; type:interface; text:Promise Promise<PermissionStatus> query(object permissionDesc); }; -<<<<<<< HEAD

            `query()` method

            @@ -519,6 +521,15 @@ spec:webidl; type:interface; text:Promise permissionDesc:

              +
            1. + If [=this=] [=relevant global object=] is a {{Window}} object, then: +
                +
              1. If the [=current settings object's=] associated `Document` is not + [=Document/fully active=], return [=a promise rejected with=] a + {{"InvalidStateError"}} {{DOMException}}. +
              2. +
              +
            2. Let |rootDesc| be the object |permissionDesc| refers to, converted to an IDL value of type {{PermissionDescriptor}}. If this throws an exception, return a promise rejected with that exception and abort @@ -551,50 +562,6 @@ spec:webidl; type:interface; text:Promise found in the Examples section.
            -======= -

            - When the query(permissionDesc) method is - invoked, the user agent MUST run the following query a - permission algorithm, passing the parameter - permissionDesc: -

            -
              -
            1. If the [=current settings object=]'s [=associated Document=] is not - [=Document/fully active=], return [=a promise rejected with=] a - "InvalidStateError" {{DOMException}}. -
            2. -
            3. Let |rootDesc| be the object |permissionDesc| refers to, converted to - an IDL value of type {{PermissionDescriptor}}. If this throws an - exception, return a promise rejected with that exception and abort - these steps. -
            4. -
            5. Let |typedDescriptor| be the object |permissionDesc| refers to, - converted to an IDL value of - |rootDesc|.{{PermissionDescriptor/name}}'s permission - descriptor type. If this throws an exception, return a promise - rejected with that exception and abort these steps. -
            6. -
            7. Let promise be a newly-created {{Promise}}. -
            8. -
            9. Return promise and continue the following steps - asynchronously. -
            10. -
            11. Run the steps to create a PermissionStatus for |typedDescriptor|, - and let status be the result. -
            12. -
            13. - Run |status|@{{PermissionStatus/[[query]]}}.{{PermissionDescriptor/name}}'s permission query - algorithm, passing |status|@{{PermissionStatus/[[query]]}} and |status|. -
            14. -
            15. Resolve promise with status. -
            16. -
            -
            - If a developer wants to check multiple permissions at once, the editors - recommend the use of {{Promise}}.all(). An example can be - found in the Examples section. -
            ->>>>>>> beadff4 (Handle not fully active documents when querying Permissions API)