summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/dom-overlay/nested_fullscreen.https.html
blob: a8fc70fca6a7c33af4287d92a4318cca621ca0bd (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!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 src="../resources/webxr_util.js"></script>
<script src="../resources/webxr_test_constants.js"></script>
<script src="../resources/webxr_test_asserts.js"></script>

<style type="text/css">
  div {
      padding: 10px;
      min-width: 10px;
      min-height: 10px;
  }
  iframe {
    border: 0;
    width: 20px;
    height: 20px;
  }
</style>
<div id="div_overlay">
  <canvas>
  </canvas>
</div>
<div id="div_other">
  <p>test text</p>
</div>

<script>

const fakeDeviceInitParams = {
  supportedModes: ["immersive-ar"],
  views: VALID_VIEWS,
  viewerOrigin: IDENTITY_TRANSFORM,
  supportedFeatures: ALL_FEATURES,
};

// This test verifies that WebXR DOM Overlay mode works when the document is
// already in fullscreen mode when the session starts. (This should work both
// for a fullscreen-based overlay implementation and for one that treats the
// overlay as an independent output.)
promise_test(
  async (setup) => {
    setup.add_cleanup(() => document.exitFullscreen());

    // Fullscreen the <body> element before running the test. Currently, this
    // can't be an arbitrary element because the simulateUserActivation call
    // adds a button to <body> which is only clickable if it's visible.
    await test_driver.bless("fullscreen",
                            () => document.body.requestFullscreen());

    const overlayElement = document.getElementById('div_overlay');

    xr_session_promise_test(
      "Check XR session from fullscreen",
      (session, fakeDeviceController, t) => {
        // The overlay element should have a transparent background.
        assert_equals(window.getComputedStyle(overlayElement).backgroundColor,
                      'rgba(0, 0, 0, 0)');

        // Check that the pseudostyle is set.
        assert_equals(document.querySelector(':xr-overlay'), overlayElement);

        // Wait for one animation frame before exiting.
        return new Promise((resolve) => session.requestAnimationFrame(resolve));
      },
      fakeDeviceInitParams, 'immersive-ar', {
        requiredFeatures: ['dom-overlay'],
        domOverlay: { root: overlayElement }
      }
    );

    // The setup promise_test automatically succeeds if it gets here
    // without raising an exception. It'll pass even on systems that
    // don't support WebXR or DOM Overlay.
  },
  "fullscreen setup"
);

</script>