forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sensor] Set permissions in WPT tests
Thanks to the new set_permission method on test_runner, this CL makes sure the sensor WPT tests with first granted permission and adds tests for sensor permission status. Change-Id: Id72e60f92043986c3fe3517faf0c79716a1f03c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2104654 Reviewed-by: Raphael Kubo da Costa <[email protected]> Reviewed-by: Reilly Grant <[email protected]> Commit-Queue: Wanming Lin <[email protected]> Cr-Commit-Position: refs/heads/master@{#751207}
- Loading branch information
1 parent
175d843
commit d18df87
Showing
3 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>sensor: permission</title> | ||
<link rel="help" href="https://w3c.github.io/sensors/"/> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script> | ||
|
||
"use strict"; | ||
|
||
for (const entry of ['accelerometer', 'gyroscope', | ||
'magnetometer', 'ambient-light-sensor']) { | ||
promise_test(async t => { | ||
await test_driver.set_permission({ name: entry }, 'denied', false); | ||
|
||
const status = await navigator.permissions.query({ name: entry }); | ||
assert_class_string(status, "PermissionStatus"); | ||
assert_equals(status.state, "denied"); | ||
}, `Deny ${entry} permission should work.`); | ||
|
||
promise_test(async t => { | ||
await test_driver.set_permission({ name: entry }, 'granted', false); | ||
|
||
const status = await navigator.permissions.query({ name: entry }); | ||
assert_class_string(status, "PermissionStatus"); | ||
assert_equals(status.state, "granted"); | ||
}, `Grant ${entry} permission should work.`); | ||
}; | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters