Files
tubestation/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
Wei Lee 8b3e2a3d0f Bug 1665842 [wpt PR 25614] - Reland "idle-detection: Implement requestPermission() method", a=testonly
Automatic update from web-platform-tests
Reland "idle-detection: Implement requestPermission() method"

This reverts commit b49f79c472eefc9c51973be205e07cb397f68589.

Reason for revert: https://crbug.com/1129639

Original change's description:
> Revert "idle-detection: Implement requestPermission() method"
>
> This reverts commit 67a8dbc31af629c51d6661c1b1d6da4218258ad8.
>
> Reason for revert: https://crbug.com/1129639
>
> Original change's description:
> > 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}
>
> TBR=reillyg@chromium.org,arthursonzogni@chromium.org,ayui@chromium.org
>
> Change-Id: I41401a81e0e75613340ebe8aa5665c3d1a45414c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 878979
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417473
> Reviewed-by: Shik Chen <shik@chromium.org>
> Commit-Queue: Shik Chen <shik@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#808208}

TBR=shik@chromium.org,reillyg@chromium.org,arthursonzogni@chromium.org,ayui@chromium.org

Bug: 878979
Change-Id: I4f409d8f37091f384883c22a39e08f7e45762aa9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417779
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: Wei Lee <wtlee@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808280}

--

wpt-commits: 79da77bc663d4be74b6fbc0e175d3c0db7f5d2bc
wpt-pr: 25614
2020-09-23 09:03:01 +00:00

99 lines
2.9 KiB
JavaScript

// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: title=Idle Detection API: Basics
'use strict';
promise_setup(async t => {
await test_driver.set_permission({name: 'idle-detection'}, 'granted', false);
})
promise_test(async t => {
let detector = new IdleDetector();
let watcher = new EventWatcher(t, detector, ["change"]);
let initial_state = watcher.wait_for("change");
await detector.start();
await initial_state;
assert_true(['active', 'idle'].includes(detector.userState),
'has a valid user state');
assert_true(['locked', 'unlocked'].includes(detector.screenState),
'has a valid screen state');
}, 'start() basics');
promise_test(async t => {
let used = false;
const detector = new IdleDetector();
detector.start({
get threshold() {
used = true;
return 60000;
}
});
assert_true(used, 'start() options "threshold" member was used');
}, 'start() uses threshold property');
promise_test(async t => {
let used = false;
const controller = new AbortController();
const detector = new IdleDetector();
detector.start({
get signal() {
used = true;
return controller.signal;
}
});
assert_true(used, 'start() options "signal" member was used');
}, 'start() uses signal property');
promise_test(async t => {
const detector = new IdleDetector();
await promise_rejects_js(t, TypeError, detector.start({threshold: 0}));
}, 'start() rejects with invalid threshold (0)');
promise_test(async t => {
const detector = new IdleDetector();
await promise_rejects_js(t, TypeError, detector.start({threshold: 59000}));
}, 'start() rejects with threshold below minimum (59000)');
promise_test(async t => {
const detector = new IdleDetector();
await detector.start({threshold: 60000});
}, 'start() rejects threshold (60000)');
promise_test(async t => {
const detector = new IdleDetector();
await detector.start({threshold: 61000});
}, 'start() allows threshold (61000)');
promise_test(async t => {
const detector = new IdleDetector();
await promise_rejects_js(t, TypeError, detector.start({threshold: null}));
}, 'start() rejects with invalid threshold (null)');
promise_test(async t => {
const detector = new IdleDetector();
await promise_rejects_js(t, TypeError, detector.start({threshold: -1}));
}, 'start() rejects with invalid threshold (-1)');
promise_test(async t => {
const detector = new IdleDetector();
await promise_rejects_js(t, TypeError, detector.start({threshold: NaN}));
}, 'start() rejects with invalid threshold (NaN)');
promise_test(async t => {
const detector = new IdleDetector();
await detector.start();
}, 'start() uses a default value for the threshold when none is passed');
promise_test(async t => {
const detector = new IdleDetector();
await detector.start({threshold: undefined});
}, 'start() uses a default value for the threshold');