Skip to content

Commit

Permalink
editorial: Remove the "obtain a permission" algorithm.
Browse files Browse the repository at this point in the history
This may have made more sense back when we had a custom
`WakeLockPermissionDescriptor`, but even then this felt like implementing a
custom permission model for no reason.

We are just interested in knowing whether we have permission to request a
wake lock from the platform, and we can use the Permission spec's "request
permission to use" algorithm for that just fine.

One important change is related to checking transient activation: the
"obtain a permission" algorithm essentially denied requests when
"screen-wake-lock"'s permission state was set to "prompt" AND there was no
transient user activation. In general, an API should either always or never
be user-activation gated. Given Blink is the only current implementation of
this spec and it does not currently gate this API on user activation, the
transient user activation check was removed altogether for now.

Together with w3c#297, this fixes w3c#187 and fixes w3c#198.
  • Loading branch information
Raphael Kubo da Costa committed Mar 2, 2021
1 parent 9fb419f commit dcf96b1
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,31 +219,6 @@ <h2>
</ol>
</li>
</ol>
<p>
To <dfn>obtain permission</dfn> for <a>wake lock type</a> |name|, run
these steps <a>in parallel</a>. This async algorithm returns either
{{PermissionState/"granted"}} or {{PermissionState/"denied"}}.
</p>
<aside class="note">
The following algorithm is defined in this specification because the
Permissions specification currently lacks integration with the
concept of user activation from [[HTML]]. See <a href=
"https://github.com/w3c/permissions/issues/194">this issue for more
information</a>.
</aside>
<ol class="algorithm">
<li>Let |state:PermissionState| be <a>permission state</a> of the
`"screen-wake-lock"` {{PermissionName}}.
</li>
<li>If |state| is not {{PermissionState/"prompt"}}, return |state|.
</li>
<li>If the <a>current global object</a> does not have [=transient
activation=], return {{PermissionState/"denied"}}.
</li>
<li>Otherwise, return the result of <a>requesting permission to
use</a> the `"screen-wake-lock"` {{PermissionName}}.
</li>
</ol>
</section>
</section>
<section>
Expand Down Expand Up @@ -371,8 +346,8 @@ <h3>
<a>Abort when</a> the steps to <a>determine the visibility
state</a> return `hidden`.
</li>
<li>Let |state:PermissionState| be the result of awaiting
<a>obtain permission</a> steps with "`screen-wake-lock`".
<li>Let |state:PermissionState| be the result of <a>requesting
permission to use</a> "`screen-wake-lock`".
</li>
<li data-tests="wakelock-request-denied.https.html">If |state| is
{{PermissionState/"denied"}}, then:
Expand Down

0 comments on commit dcf96b1

Please sign in to comment.