diff --git a/index.html b/index.html index 54d1b09..7320ccb 100644 --- a/index.html +++ b/index.html @@ -203,8 +203,8 @@

Wake Lock permission revocation algorithm, run these steps:

    -
  1. Let |document:Document| be the [=environment settings object / - responsible document=] of the current settings object. +
  2. Let |document:Document| the [=current settings object=]'s + [=associated Document=].
  3. Let |record| be the platform wake lock's state record associated with |document| and wake lock type @@ -213,37 +213,11 @@

  4. [=list/For each=] |lock:WakeLockSentinel| in |record|.{{[[ActiveLocks]]}}:
      -
    1. Run release a wake lock with |lock| and - {{WakeLockType/"screen"}}. +
    2. Run release a wake lock with |document| and |lock|.
-

- To obtain permission for wake lock type |name|, run - these steps in parallel. This async algorithm returns either - {{PermissionState/"granted"}} or {{PermissionState/"denied"}}. -

- -
    -
  1. Let |state:PermissionState| be permission state of the - `"screen-wake-lock"` {{PermissionName}}. -
  2. -
  3. If |state| is not {{PermissionState/"prompt"}}, return |state|. -
  4. -
  5. If the current global object does not have [=transient - activation=], return {{PermissionState/"denied"}}. -
  6. -
  7. Otherwise, return the result of requesting permission to - use the `"screen-wake-lock"` {{PermissionName}}. -
  8. -
@@ -266,8 +240,8 @@

Each platform wake lock (one per wake lock type) has an - associated state record per [=environment settings object / - responsible document=] with the following state record per {{Document}} with the following + internal slots:

@@ -295,8 +269,7 @@

A list of {{WakeLockSentinel}} objects, representing - active wake locks associated with the [=environment settings - object / responsible document=]. + active wake locks associated with the {{Document}}. @@ -337,8 +310,8 @@

|type:WakeLockType|:

    -
  1. Let |document:Document| be the [=environment settings object / - responsible document=] of the current settings object. +
  2. Let |document:Document| the [=current settings object=]'s + [=associated Document=].
    1. If @@ -367,30 +340,36 @@

      return [=a promise rejected with=] {{"NotAllowedError"}} {{DOMException}}.

    2. +
    3. If the current global object does not have [=transient + activation=], return [=a promise rejected with=] + {{"NotAllowedError"}} {{DOMException}}. +
    4. Let |promise:Promise| be [=a new promise=].
    5. -
    6. Return |promise| and run the following steps in parallel: +
    7. Run the following steps in parallel:
      1. Abort when the steps to determine the visibility state return `hidden`.
      2. -
      3. Let |state:PermissionState| be the result of awaiting - obtain permission steps with "`screen-wake-lock`": +
      4. Let |state:PermissionState| be the result of requesting + permission to use the `"screen-wake-lock"` + {{PermissionName}}. +
      5. +
      6. If |state| is + {{PermissionState/"denied"}}, then:
          -
        1. If - |state| is {{PermissionState/"denied"}}, then reject - |promise| with a {{"NotAllowedError"}} {{DOMException}}, and - abort these steps. +
        2. [=Queue a global task=] on the [=screen wake lock task + source=] given |document|'s [=relevant global object=] to + [=reject=] |promise| with a {{"NotAllowedError"}} + {{DOMException}}. +
        3. +
        4. Abort these steps.
      7. -
      8. Let |lock:WakeLockSentinel| be a new {{WakeLockSentinel}} - object with its {{WakeLockSentinel/type}} attribute set to - |type|. -
      9. -
      10. Invoke acquire a wake lock with |lock| and - {{WakeLockType/"screen"}}. +
      11. Invoke acquire a wake lock with |document|, |type|, + and |promise|.
      12. -
      13. Resolve |promise| with |lock|. -
    8. If aborted, reject |promise| with a {{"NotAllowedError"}} {{DOMException}}.
    9. +
    10. Return |promise|. +

@@ -509,20 +488,13 @@

following steps:

    -
  1. If this' {{[[Released]]}} internal slot is `true`, return +
  2. If this's {{[[Released]]}} internal slot is `true`, return a promise resolved with `undefined`.
  3. Otherwise, let |promise:Promise| be a new promise.
  4. -
  5. Run the following steps in parallel: -
      -
    1. Run release a wake lock with |lock:WakeLockSentinel| - set to this and |type:WakeLockType| set to the value of - this' {{WakeLockSentinel/type}} attribute. -
    2. -
    3. Resolve |promise|. -
    4. -
    +
  6. Run release a wake lock given the [=current global + object=]'s [=associated Document=], [=this=], and |promise|.
  7. Return |promise|.
  8. @@ -640,14 +612,10 @@

    Handling document loss of full activity

    - When the user agent determines that a [=environment settings object / - responsible document=] of the current settings object is no - longer [=Document/fully active=], it must run these steps: + When a {{Document}} |document:Document| becomes no longer + [=Document/fully active=], the user agent must run these steps:

      -
    1. Let |document:Document| be the [=environment settings object / - responsible document=] of the current settings object. -
    2. Let |screenRecord| be the platform wake lock's state record associated with |document| and wake lock type {{WakeLockType/"screen"}}. @@ -655,8 +623,7 @@

    3. [=list/For each=] |lock:WakeLockSentinel| in |screenRecord|.{{[[ActiveLocks]]}}:
        -
      1. Run release a wake lock with |lock| and - {{WakeLockType/"screen"}}. +
      2. Run release a wake lock with |document| and |lock|.
    4. @@ -675,14 +642,11 @@

      the latest TR, so we cannot reference them yet. -->

      When the user agent determines that the [=Document/visibility state=] - of the Document of the top-level browsing context has - become `hidden`, the user agent MUST run the following steps after - the now hidden algorithm: + of a {{Document}} |document:Document| of a top-level browsing + context has become `hidden`, the user agent MUST run the + following steps after the now hidden algorithm:

        -
      1. Let |document:Document| be the [=environment settings object / - responsible document=] of the current settings object. -
      2. Let |screenRecord| be the platform wake lock's state record associated with |document| and wake lock type {{WakeLockType/"screen"}}. @@ -690,8 +654,7 @@

      3. [=list/For each=] |lock:WakeLockSentinel| in |screenRecord|.{{[[ActiveLocks]]}}:
          -
        1. Run release a wake lock with |lock| and - {{WakeLockType/"screen"}}. +
        2. Run release a wake lock with |document| and |lock|.
      4. @@ -706,8 +669,8 @@

        Acquire wake lock algorithm

        - To acquire a wake lock for a given |lock:WakeLockSentinel| - and |type:WakeLockType|, run these steps in parallel: + To acquire a wake lock given a |document:Document|, a + |type:WakeLockType|, and a |promise:Promise|:

        1. If the wake lock for type |type| is not applicable, abort @@ -719,13 +682,22 @@

        2. Ask the underlying operating system to acquire the wake lock of type |type|.
        3. -
        4. Let |document:Document| be the [=environment settings object / - responsible document=] of the current settings object. -
        5. -
        6. Let |record| be the platform wake lock's state - record associated with |document| and |type|. -
        7. -
        8. Add |lock| to |record|.{{[[ActiveLocks]]}}. +
        9. [=Queue a global task=] on the [=screen wake lock task source=] + given |document|'s [=relevant global object=] to perform the + following steps: +
            +
          1. Let |record| be the platform wake lock's state + record associated with |document| and |type|. +
          2. +
          3. Let |lock:WakeLockSentinel| be a new {{WakeLockSentinel}} + object with its {{WakeLockSentinel/type}} attribute set to + |type|. +
          4. +
          5. Add |lock| to |record|.{{[[ActiveLocks]]}}. +
          6. +
          7. [=Resolve=] |promise| with |lock|. +
          8. +
        @@ -734,12 +706,12 @@

        Release wake lock algorithm

        - To release a wake lock for a given |lock:WakeLockSentinel| - and |type:WakeLockType|, run these steps in parallel: + To release a wake lock given a |document:Document|, a + |lock:WakeLockSentinel|, and an optional |promise:Promise|:

          -
        1. Let |document:Document| be the [=environment settings object / - responsible document=] of the current settings object. +
        2. Let |type:WakeLockType| be the value of |lock|'s + {{WakeLockSentinel/type}} attribute.
        3. Let |record| be the platform wake lock's state record associated with |document| and |type|. @@ -771,14 +743,17 @@

      5. -
      6. - Queue a task to run the following steps: +
      7. [=Queue a global task=] on the [=screen wake lock task source=] + given |document|'s [=relevant global object=] to run the following + steps:
        1. Set |lock|'s {{[[Released]]}} internal slot to `true`.
        2. Fire an event named "`release`" at |lock|.
        3. +
        4. If |promise| was given, then [=resolve=] |promise|. +