- To obtain permission for wake lock type |name|, run
- these steps in parallel. This async algorithm returns either
- {{PermissionState/"granted"}} or {{PermissionState/"denied"}}.
-
-
-
-
Let |state:PermissionState| be permission state of the
- `"screen-wake-lock"` {{PermissionName}}.
-
-
If |state| is not {{PermissionState/"prompt"}}, return |state|.
-
-
If the current global object does not have [=transient
- activation=], return {{PermissionState/"denied"}}.
-
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|:
-
Let |document:Document| be the [=environment settings object /
- responsible document=] of the current settings object.
+
Let |document:Document| the [=current settings object=]'s
+ [=associated Document=].
Let |state:PermissionState| be the result of awaiting
- obtain permission steps with "`screen-wake-lock`":
+
Let |state:PermissionState| be the result of requesting
+ permission to use the `"screen-wake-lock"`
+ {{PermissionName}}.
+
+
If |state| is
+ {{PermissionState/"denied"}}, then:
-
If
- |state| is {{PermissionState/"denied"}}, then reject
- |promise| with a {{"NotAllowedError"}} {{DOMException}}, and
- abort these steps.
+
[=Queue a global task=] on the [=screen wake lock task
+ source=] given |document|'s [=relevant global object=] to
+ [=reject=] |promise| with a {{"NotAllowedError"}}
+ {{DOMException}}.
+
+
Abort these steps.
-
Let |lock:WakeLockSentinel| be a new {{WakeLockSentinel}}
- object with its {{WakeLockSentinel/type}} attribute set to
- |type|.
-
Run release a wake lock with |lock:WakeLockSentinel|
- set to this and |type:WakeLockType| set to the value of
- this' {{WakeLockSentinel/type}} attribute.
-
-
Resolve |promise|.
-
-
+
Run release a wake lock given the [=current global
+ object=]'s [=associated Document=], [=this=], and |promise|.
Return |promise|.
@@ -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:
-
Let |document:Document| be the [=environment settings object /
- responsible document=] of the current settings object.
-
- 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|:
If the wake lock for type |type| is not applicable, abort
@@ -719,13 +682,22 @@
Let |lock:WakeLockSentinel| be a new {{WakeLockSentinel}}
+ object with its {{WakeLockSentinel/type}} attribute set to
+ |type|.
+
+
Add |lock| to |record|.{{[[ActiveLocks]]}}.
+
+
[=Resolve=] |promise| with |lock|.
+
+
@@ -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|:
-
Let |document:Document| be the [=environment settings object /
- responsible document=] of the current settings object.
+
Let |type:WakeLockType| be the value of |lock|'s
+ {{WakeLockSentinel/type}} attribute.