summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/device-posture
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /testing/web-platform/tests/device-posture
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/device-posture')
-rw-r--r--testing/web-platform/tests/device-posture/device-posture-change-event.https.html23
-rw-r--r--testing/web-platform/tests/device-posture/device-posture-clear.https.html29
-rw-r--r--testing/web-platform/tests/device-posture/device-posture-event-listener.https.html25
-rw-r--r--testing/web-platform/tests/device-posture/device-posture-media-queries.https.html27
4 files changed, 104 insertions, 0 deletions
diff --git a/testing/web-platform/tests/device-posture/device-posture-change-event.https.html b/testing/web-platform/tests/device-posture/device-posture-change-event.https.html
new file mode 100644
index 0000000000..eb2fc2d96f
--- /dev/null
+++ b/testing/web-platform/tests/device-posture/device-posture-change-event.https.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<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';
+
+promise_test(async (t) => {
+ t.add_cleanup(async () => {
+ await test_driver.clear_device_posture();
+ });
+ const watcher = new EventWatcher(t, navigator.devicePosture, ['change']);
+ const postures = ['folded', 'continuous', 'folded'];
+ for (const posture of postures) {
+ await Promise.all([
+ watcher.wait_for('change'),
+ test_driver.set_device_posture(posture)
+ ]);
+ assert_equals(posture, navigator.devicePosture.type);
+ }
+}, 'Tests the Device Posture API change event handler.');
+</script>
diff --git a/testing/web-platform/tests/device-posture/device-posture-clear.https.html b/testing/web-platform/tests/device-posture/device-posture-clear.https.html
new file mode 100644
index 0000000000..319cd7266a
--- /dev/null
+++ b/testing/web-platform/tests/device-posture/device-posture-clear.https.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<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';
+
+promise_test(async (t) => {
+ t.add_cleanup(async () => {
+ await test_driver.clear_device_posture();
+ });
+ const originalPosture = navigator.devicePosture.type;
+ const posture = originalPosture ? 'folded' : 'continuous';
+
+ const watcher = new EventWatcher(t, navigator.devicePosture, ['change']);
+ await Promise.all([
+ watcher.wait_for('change'),
+ test_driver.set_device_posture(posture)
+ ]);
+ assert_equals(navigator.devicePosture.type, posture);
+
+ await Promise.all([
+ watcher.wait_for('change'),
+ test_driver.clear_device_posture()
+ ]);
+ assert_equals(navigator.devicePosture.type, originalPosture);
+}, 'Tests that device posture override can be removed.');
+</script>
diff --git a/testing/web-platform/tests/device-posture/device-posture-event-listener.https.html b/testing/web-platform/tests/device-posture/device-posture-event-listener.https.html
new file mode 100644
index 0000000000..f4e21c89cc
--- /dev/null
+++ b/testing/web-platform/tests/device-posture/device-posture-event-listener.https.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<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';
+
+promise_test(async (t) => {
+ t.add_cleanup(async () => {
+ await test_driver.clear_device_posture();
+ });
+ assert_equals(navigator.devicePosture.type, 'continuous');
+
+ const promise = new Promise(resolve => {
+ navigator.devicePosture.addEventListener(
+ 'change',
+ () => { resolve(navigator.devicePosture.type); },
+ { once: true }
+ );
+ });
+ await test_driver.set_device_posture('folded');
+ assert_equals(await promise, 'folded');
+}, 'Tests the Device Posture API addEventListener change event handler.');
+</script>
diff --git a/testing/web-platform/tests/device-posture/device-posture-media-queries.https.html b/testing/web-platform/tests/device-posture/device-posture-media-queries.https.html
new file mode 100644
index 0000000000..e4dbd2e7d8
--- /dev/null
+++ b/testing/web-platform/tests/device-posture/device-posture-media-queries.https.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<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';
+
+promise_test(async (t) => {
+ t.add_cleanup(async () => {
+ await test_driver.clear_device_posture();
+ });
+ assert_equals(navigator.devicePosture.type, 'continuous');
+ assert_true(matchMedia('(device-posture: continuous)').matches);
+
+ const foldedMQL = window.matchMedia('(device-posture: folded)');
+ const promise = new Promise(resolve => {
+ foldedMQL.addEventListener(
+ 'change',
+ () => { resolve(foldedMQL.matches); },
+ { once: true }
+ );
+ });
+ await test_driver.set_device_posture('folded');
+ assert_true(await promise);
+}, 'Tests the Device Posture API Media Query change event handler.');
+</script>