summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/device-posture/device-posture-media-queries.https.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/device-posture/device-posture-media-queries.https.html')
-rw-r--r--testing/web-platform/tests/device-posture/device-posture-media-queries.https.html27
1 files changed, 27 insertions, 0 deletions
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>