device-posture-media-queries.https.html (887B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testdriver.js"></script> 5 <script src="/resources/testdriver-vendor.js"></script> 6 <script> 7 'use strict'; 8 9 promise_test(async (t) => { 10 t.add_cleanup(async () => { 11 await test_driver.clear_device_posture(); 12 }); 13 assert_equals(navigator.devicePosture.type, 'continuous'); 14 assert_true(matchMedia('(device-posture: continuous)').matches); 15 16 const foldedMQL = window.matchMedia('(device-posture: folded)'); 17 const promise = new Promise(resolve => { 18 foldedMQL.addEventListener( 19 'change', 20 () => { resolve(foldedMQL.matches); }, 21 { once: true } 22 ); 23 }); 24 await test_driver.set_device_posture('folded'); 25 assert_true(await promise); 26 }, 'Tests the Device Posture API Media Query change event handler.'); 27 </script>