summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/idle-detection/basics.tentative.https.window.js')
-rw-r--r--testing/web-platform/tests/idle-detection/basics.tentative.https.window.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js b/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
new file mode 100644
index 0000000000..32cb6204b9
--- /dev/null
+++ b/testing/web-platform/tests/idle-detection/basics.tentative.https.window.js
@@ -0,0 +1,98 @@
+// 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');
+})
+
+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');