summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/device-posture/device-posture-media-queries.https.html
blob: e4dbd2e7d81d3c3fc088283adc6b884ed4109018 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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>