From f90f00befb189614649f9978a607cb915bd94c4a Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 4 Jul 2024 10:23:05 +1000 Subject: [PATCH 1/9] Add document fully active checks --- index.bs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 50465ba..31bdf23 100644 --- a/index.bs +++ b/index.bs @@ -294,13 +294,15 @@ The absolute attribute must re The requestPermission(|absolute|) 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 |document| be |global|'s [=associated Document=]. + 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. + 1. Let |hadTransientActivation| 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 |permissions| be « "accelerometer", "gyroscope" ». 1. If |absolute| is true, [=set/append=] "magnetometer" » to |permissions|. 1. Run these steps in parallel: 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}}". @@ -342,6 +344,8 @@ To fire an orientation event given a {{DOMString}} |event|, {{Window} 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. 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. @@ -517,6 +521,8 @@ The interval attribute must return The requestPermission() method steps are: 1. Let |global| be the [=current global object=]. + 1. Let |document| be |global|'s [=associated Document=]. + 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. 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. Run these steps in parallel: @@ -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 "devicemotion" 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|. From 0a0614d8af77d9403925eea9eb62e67a53620a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 4 Jul 2024 10:24:12 +1000 Subject: [PATCH 2/9] Update index.bs --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 31bdf23..3aa8ba7 100644 --- a/index.bs +++ b/index.bs @@ -296,7 +296,7 @@ The requestPermission(|absolute|) 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 1. Let |hadTransientActivation| be true if [=this=]'s [=relevant global object=] has [=transient activation=], and false otherwise. + 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise. 1. Let |promise| be [=a new promise=] in [=this=]'s [=relevant Realm=]. 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. If |absolute| is true, [=set/append=] "magnetometer" » to |permissions|. From b5af1ee97312cafb4db3212b30ba6fc4ba9fa07c Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 4 Jul 2024 10:31:06 +1000 Subject: [PATCH 3/9] this/global usage --- index.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.bs b/index.bs index 3aa8ba7..05e06a9 100644 --- a/index.bs +++ b/index.bs @@ -296,8 +296,8 @@ The requestPermission(|absolute|) 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise. - 1. Let |promise| be [=a new promise=] in [=this=]'s [=relevant Realm=]. + 1. Let |hadTransientActivation| be |global| has [=transient activation=], and false otherwise. + 1. Let |promise| be [=a new promise=] in |global|'s [=relevant Realm=]. 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. If |absolute| is true, [=set/append=] "magnetometer" » to |permissions|. 1. Run these steps in parallel: @@ -523,8 +523,8 @@ The requestPermission() method steps a 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 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 |hasTransientActivation| be true if |global| has [=transient activation=], and false otherwise. + 1. Let |result| be [=a new promise=] in |global|'s [=relevant Realm=]. 1. Run these steps in parallel: 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. [=list/For each=] |name| of |permissions|: From db56048ceeb26a05d4cf1b2f5a1e13053459cad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 4 Jul 2024 10:32:07 +1000 Subject: [PATCH 4/9] Update index.bs --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 05e06a9..9324244 100644 --- a/index.bs +++ b/index.bs @@ -523,7 +523,7 @@ The requestPermission() method steps a 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 1. Let |hasTransientActivation| be true if |global| has [=transient activation=], and false otherwise. + 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise. 1. Let |result| be [=a new promise=] in |global|'s [=relevant Realm=]. 1. Run these steps in parallel: 1. Let |permissions| be « "accelerometer", "gyroscope" ». From 5b2b82676f8b2075bfb529339feb57b2e40aece0 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 4 Jul 2024 10:33:05 +1000 Subject: [PATCH 5/9] has/had --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 9324244..32b6281 100644 --- a/index.bs +++ b/index.bs @@ -528,7 +528,7 @@ The requestPermission() method steps a 1. Run these steps in parallel: 1. Let |permissions| be « "accelerometer", "gyroscope" ». 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=] |result| with a "{{NotAllowedError}}" {{DOMException}}. 1. Return. 1. Let |permissionState| be "{{PermissionState/granted}}". From 0e9a39b9c99e857478f6677c8850c0a30dab344d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 4 Jul 2024 10:36:45 +1000 Subject: [PATCH 6/9] Update index.bs --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 32b6281..3409d6c 100644 --- a/index.bs +++ b/index.bs @@ -296,7 +296,7 @@ The requestPermission(|absolute|) 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 1. Let |hadTransientActivation| be |global| has [=transient activation=], and false otherwise. + 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise. 1. Let |promise| be [=a new promise=] in |global|'s [=relevant Realm=]. 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. If |absolute| is true, [=set/append=] "magnetometer" » to |permissions|. From e82e307a2943e1f012701c2110e864fdbdfd7588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 4 Jul 2024 10:37:23 +1000 Subject: [PATCH 7/9] Update index.bs --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 3409d6c..1a8e9b7 100644 --- a/index.bs +++ b/index.bs @@ -523,7 +523,7 @@ The requestPermission() method steps a 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise. + 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=]. 1. Run these steps in parallel: 1. Let |permissions| be « "accelerometer", "gyroscope" ». From 19c5e03d42eac266f00794485bac4d2661fddf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 4 Jul 2024 10:37:44 +1000 Subject: [PATCH 8/9] Apply suggestions from code review --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 1a8e9b7..16f8d35 100644 --- a/index.bs +++ b/index.bs @@ -296,7 +296,7 @@ The requestPermission(|absolute|) 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. - 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], and false otherwise. + 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], or false otherwise. 1. Let |promise| be [=a new promise=] in |global|'s [=relevant Realm=]. 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. If |absolute| is true, [=set/append=] "magnetometer" » to |permissions|. From ec6f4a8b3d0c258a317faf8bedfb441e63652299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Wed, 10 Jul 2024 10:58:19 +1000 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Reilly Grant --- index.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.bs b/index.bs index 16f8d35..15853cf 100644 --- a/index.bs +++ b/index.bs @@ -295,9 +295,9 @@ The requestPermission(|absolute|) 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. - 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. + 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}. 1. Let |hadTransientActivation| be true if |global| has [=transient activation=], or false otherwise. - 1. Let |promise| be [=a new promise=] in |global|'s [=relevant Realm=]. + 1. Let |promise| be [=a new promise=] in |global|'s [=relevant realm=]. 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. If |absolute| is true, [=set/append=] "magnetometer" » to |permissions|. 1. Run these steps in parallel: @@ -522,9 +522,9 @@ The requestPermission() method steps a 1. Let |global| be the [=current global object=]. 1. Let |document| be |global|'s [=associated Document=]. - 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] "{{InvalidStateError}}" {{DOMException}}. + 1. If |document| is not [=document/fully active=], return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}. 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=]. + 1. Let |result| be [=a new promise=] in |global|'s [=relevant realm=]. 1. Run these steps in parallel: 1. Let |permissions| be « "accelerometer", "gyroscope" ». 1. [=list/For each=] |name| of |permissions|: