зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1663089 [wpt PR 25399] - idle-detection: Implement requestPermission() method, a=testonly
Automatic update from web-platform-tests idle-detection: Implement requestPermission() method This change implements a static requestPermission() method on the IdleDetector interface and switches the API from requiring the "notifications" permission to the new "idle-detector" permission. Bug: 878979 Change-Id: If2162f6a1f770544aeb82f98fcc65a76059b7d13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359539 Auto-Submit: Reilly Grant <reillyg@chromium.org> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Commit-Queue: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#808019} -- wpt-commits: 80c4b6a039de41d75eec3845fec5fc8ade50c390 wpt-pr: 25399
This commit is contained in:
Родитель
3fd17f2db0
Коммит
78bb08289f
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
promise_setup(async t => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({name: 'idle-detection'}, 'granted', false);
|
||||
})
|
||||
|
||||
promise_test(async t => {
|
||||
|
|
|
@ -21,7 +21,7 @@ const cross_origin_worker_frame_src = base_src + sub +
|
|||
relative_worker_frame_path;
|
||||
|
||||
promise_setup(async () => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({ name: 'idle-detection' }, 'granted', false);
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
|
|
|
@ -17,7 +17,7 @@ const cross_origin_src = sub + same_origin_src;
|
|||
const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;
|
||||
|
||||
promise_setup(async () => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({ name: 'idle-detection' }, 'granted', false);
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
|
|
|
@ -17,7 +17,7 @@ const cross_origin_src = sub + same_origin_src;
|
|||
const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;
|
||||
|
||||
promise_setup(async () => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({ name: 'idle-detection' }, 'granted', false);
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
|
|
|
@ -14,7 +14,7 @@ const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
|
|||
same_origin_src;
|
||||
|
||||
promise_setup(async () => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({ name: 'idle-detection' }, 'granted', false);
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
|
|
|
@ -3,22 +3,32 @@
|
|||
'use strict';
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.set_permission(
|
||||
{ name: 'notifications' }, 'denied', false);
|
||||
await test_driver.set_permission({name: 'idle-detection'}, 'denied', false);
|
||||
|
||||
let detector = new IdleDetector();
|
||||
await promise_rejects_dom(t, 'NotAllowedError', detector.start());
|
||||
}, "Deny notifications permission should work.");
|
||||
let detector = new IdleDetector();
|
||||
await promise_rejects_dom(t, 'NotAllowedError', detector.start());
|
||||
}, 'Denying idle-detection permission should block access.');
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.set_permission(
|
||||
{ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({name: 'idle-detection'}, 'granted', false);
|
||||
|
||||
let detector = new IdleDetector();
|
||||
await detector.start();
|
||||
let detector = new IdleDetector();
|
||||
await detector.start();
|
||||
|
||||
assert_true(['active', 'idle'].includes(detector.userState),
|
||||
'has a valid user state');
|
||||
assert_true(['locked', 'unlocked'].includes(detector.screenState),
|
||||
'has a valid screen state');
|
||||
}, "Grant notifications permission should work.");
|
||||
assert_true(
|
||||
['active', 'idle'].includes(detector.userState),
|
||||
'has a valid user state');
|
||||
assert_true(
|
||||
['locked', 'unlocked'].includes(detector.screenState),
|
||||
'has a valid screen state');
|
||||
}, 'Granting idle-detection permission should allow access.');
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.set_permission({name: 'idle-detection'}, 'prompt', false);
|
||||
|
||||
await promise_rejects_dom(t, 'NotAllowedError', IdleDetector.requestPermission());
|
||||
|
||||
await test_driver.bless('request permission');
|
||||
let state = await IdleDetector.requestPermission();
|
||||
assert_equals(state, 'prompt');
|
||||
}, 'The idle-detection permission cannot be requested without a user gesture');
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
'use strict';
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({name: 'idle-detection'}, 'granted', false);
|
||||
|
||||
await fetch_tests_from_worker(new Worker('resources/idlharness-worker.js'));
|
||||
}, 'Run idlharness tests in a worker.');
|
||||
|
|
|
@ -11,7 +11,7 @@ idl_test(
|
|||
['idle-detection.tentative'],
|
||||
['dom', 'html'],
|
||||
async (idl_array, t) => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({ name: 'idle-detection' }, 'granted', false);
|
||||
|
||||
self.idle = new IdleDetector();
|
||||
let watcher = new EventWatcher(t, self.idle, ["change"]);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
'use strict';
|
||||
|
||||
promise_setup(async t => {
|
||||
await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
|
||||
await test_driver.set_permission({ name: 'idle-detection' }, 'granted', false);
|
||||
if (isChromiumBased) {
|
||||
await loadChromiumResources();
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ enum ScreenIdleState {
|
|||
readonly attribute UserIdleState? userState;
|
||||
readonly attribute ScreenIdleState? screenState;
|
||||
attribute EventHandler onchange;
|
||||
[Exposed=Window] static Promise<PermissionState> requestPermission();
|
||||
Promise<any> start(optional IdleOptions options = {});
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче