Skip to content

Commit

Permalink
WakeLock.request(): Check page visibility in the queued task.
Browse files Browse the repository at this point in the history
This should allow us to avoid requesting a lock in case there has been a
visibility change between obtaining permission and the subsequent steps.
  • Loading branch information
Raphael Kubo da Costa committed Feb 15, 2021
1 parent 7b22b76 commit 56b7230
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
xref: {
profile: "web-platform",
specs: [
"page-visibility",
"permissions",
"permissions-policy",
]
Expand Down Expand Up @@ -364,9 +365,10 @@ <h3>
|document| is not [=Document/fully active=], return [=a promise
rejected with=] with a {{"NotAllowedError"}} {{DOMException}}.
</li>
<li data-tests="wakelock-document-hidden-manual.https.html">If
|document| is <a>hidden</a>, return [=a promise rejected with=]
{{"NotAllowedError"}} {{DOMException}}.
<li data-tests="wakelock-document-hidden-manual.https.html">If the
steps to <a>determine the visibility state</a> return `hidden`,
return [=a promise rejected with=] {{"NotAllowedError"}}
{{DOMException}}.
</li>
<li>Let |record| be the <a>platform wake lock</a>'s <a>state
record</a> associated with |document| and |type|.
Expand All @@ -375,11 +377,6 @@ <h3>
</li>
<li>Run the following steps <a>in parallel</a>:
<ol>
<!--
<li>
<a>Abort when</a> |document| is <a>hidden</a>.
</li>
-->
<li>Let |state:PermissionState| be the result of awaiting
<a>obtain permission</a> steps with "`screen-wake-lock`":
<ol>
Expand All @@ -396,6 +393,10 @@ <h3>
<a>Queue a global task</a> on the <a>screen wake lock task
source</a> given |global| to run these steps:
<ol>
<li>If the steps to <a>determine the visibility state</a>
return `hidden`, reject |promise| with a
{{"NotAllowedError"}} {{DOMException}}.
</li>
<li>If |record|.{{[[ActiveLocks]]}} is [=list/empty=], then
invoke the following steps <a>in parallel</a>:
<ol>
Expand Down

0 comments on commit 56b7230

Please sign in to comment.