Skip to content

Commit 198a0c3

Browse files
author
Raphael Kubo da Costa
committed
Sensor.start(): Check for permission before attempting to connect to sensor.
This better reflects the current implementation in Chromium. Additionally, it makes more sense to check for permission and bail out early than to run "connect to sensor", failing and having to remove the connection.
1 parent 5766a8e commit 198a0c3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

index.bs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,13 @@ It represents a [=reading timestamp=].
11451145
return.
11461146
1. Set [=this=].{{[[state]]}} to "activating".
11471147
1. Run these sub-steps [=in parallel=]:
1148+
1. Let |permissionState| be the result of invoking
1149+
[=request sensor access=] with [=this=] as argument.
1150+
1. If |permissionState| is "denied", then:
1151+
1. Let |e| be the result of [=created|creating=]
1152+
a "{{NotAllowedError!!exception}}" {{DOMException}}.
1153+
1. Queue a task to run [=notify error=] with [=this=] and |e| as arguments.
1154+
1. Return.
11481155
1. Let |connected| be the result of invoking [=connect to sensor=] with [=this=]
11491156
as argument.
11501157
1. If |connected| is false, then
@@ -1162,14 +1169,7 @@ It represents a [=reading timestamp=].
11621169
but it is a tradeoff some User Agent might choose to make. -->
11631170
1. Queue a task to run [=notify error=] with [=this=] and |e| as arguments.
11641171
1. Return.
1165-
1. Let |permission_state| be the result of invoking
1166-
[=request sensor access=] with [=this=] as argument.
1167-
1. If |permission_state| is "granted",
1168-
1. Invoke [=activate a sensor object=] with [=this=] as argument.
1169-
1. Otherwise, if |permission_state| is "denied",
1170-
1. Let |e| be the result of [=created|creating=]
1171-
a "{{NotAllowedError!!exception}}" {{DOMException}}.
1172-
1. Queue a task to run [=notify error=] with [=this=] and |e| as arguments.
1172+
1. Invoke [=activate a sensor object=] with [=this=] as argument.
11731173
</div>
11741174

11751175

0 commit comments

Comments
 (0)