Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document fully active checks #187

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,15 @@ The <dfn attribute for="DeviceOrientationEvent">absolute</dfn> attribute must re
The <dfn method for="DeviceOrientationEvent">requestPermission(|absolute|)</dfn> method steps are:

1. Let |global| be the [=current global object=].
1. Let |hasTransientActivation| be true if [=this=]'s [=relevant global object=] has [=transient activation=], and false otherwise.
1. Let |promise| be [=a new promise=] in [=this=]'s [=relevant Realm=].
1. Let |document| be |global|'s [=associated Document=].
1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}.
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise.
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
1. Let |promise| be [=a new promise=] in |global|'s [=relevant Realm=].
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
1. Let |permissions| be « <a permission>"accelerometer"</a>, <a permission>"gyroscope"</a> ».
1. If |absolute| is true, [=set/append=] <a permission>"magnetometer"</a> » to |permissions|.
1. Run these steps <a>in parallel</a>:
1. [=list/For each=] |name| of |permissions|:
1. If |name|'s [=permission state=] is "{{PermissionState/prompt}}" and |hasTransientActivation| is false:
1. If |name|'s [=permission state=] is "{{PermissionState/prompt}}" and |hadTransientActivation| is false:
1. [=Queue a global task=] on the [=device motion and orientation task source=] given |global| to [=reject=] |promise| with a "{{NotAllowedError}}" {{DOMException}}.
1. Return.
1. Let |permissionState| be "{{PermissionState/granted}}".
Expand Down Expand Up @@ -342,6 +344,8 @@ To <dfn>fire an orientation event</dfn> given a {{DOMString}} |event|, {{Window}
1. Let |state| be the result of <a>getting the current permission state</a> with |permission| and |environment|.
1. If |state| is not "{{PermissionState/granted}}", return.
1. [=Queue a global task=] on the [=device motion and orientation task source=] given |window| to run the following steps:
1. If |document| is not [=document/fully active=], return.
1. If |document|'s [=Document/visibility state=] is not "`visible`", return.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right place for this check, but we should remove the duplicate checks from "deviceorientation firing steps" below.

1. Let |z| be |orientation|'s representation as intrinsic Tait-Bryan angles Z - X' - Y'' along the Z axis, or null if the implementation cannot provide an angle value.
1. If |z| is not null, limit |z|'s precision to 0.1 degrees.
1. Let |x| be |orientation|'s representation as intrinsic Tait-Bryan angles Z - X' - Y'' along the X' axis, or null if the implementation cannot provide an angle value.
Expand Down Expand Up @@ -517,12 +521,14 @@ The <dfn attribute for="DeviceMotionEvent">interval</dfn> attribute must return
The <dfn method for="DeviceMotionEvent">requestPermission()</dfn> method steps are:

1. Let |global| be the [=current global object=].
1. Let |hasTransientActivation| be true if [=this=]'s [=relevant global object=] has [=transient activation=], and false otherwise.
1. Let |result| be [=a new promise=] in [=this=]'s [=relevant Realm=].
1. Let |document| be |global|'s [=associated Document=].
1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}.
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
1. Let |hadTransientActivation| be true if |global| has [=transient activation=], or false otherwise.
1. Let |result| be [=a new promise=] in |global|'s [=relevant Realm=].
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
1. Run these steps <a>in parallel</a>:
1. Let |permissions| be « <a permission>"accelerometer"</a>, <a permission>"gyroscope"</a> ».
1. [=list/For each=] |name| of |permissions|:
1. If |name|'s <a>permission state</a> is "{{PermissionState/prompt}}" and |hasTransientActivation| is false:
1. If |name|'s <a>permission state</a> is "{{PermissionState/prompt}}" and |hadTransientActivation| is false:
1. [=Queue a global task=] on the [=device motion and orientation task source=] given |global| to [=reject=] |result| with a "{{NotAllowedError}}" {{DOMException}}.
1. Return.
1. Let |permissionState| be "{{PermissionState/granted}}".
Expand Down Expand Up @@ -597,6 +603,8 @@ At an [=implementation-defined=] interval |interval|, the user agent must execut
1. Let |state| be the result of [=getting the current permission state=] with |permission| and |environment|.
1. If |state| is not "{{PermissionState/granted}}", return.
1. [=Queue a global task=] on the [=device motion and orientation task source=] given |window| to run the following steps:
1. If |document| is not [=document/fully active=], return.
1. If |document|'s [=Document/visibility state=] is not "`visible`", return.
1. [=Fire an event=] named "<a event for="Window">devicemotion</a>" at |window|, using {{DeviceMotionEvent}}, with the {{DeviceMotionEvent/acceleration}} attribute initialized to |acceleration|, the {{DeviceMotionEvent/accelerationIncludingGravity}} attribute initialized to |accelerationIncludingGravity|, the {{DeviceMotionEvent/rotationRate}} attribute initialized to |rotationRate|, and the {{DeviceMotionEvent/interval}} attribute initialized to |interval|.

</div>
Expand Down
Loading