summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrSession_requestReferenceSpace_features.https.html
blob: a20223fca3b1ae2d04441b83680107a3de45675a (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
82
<!DOCTYPE html>
<body>
  <script src=/resources/testharness.js></script>
  <script src=/resources/testharnessreport.js></script>
  <script src="resources/webxr_util.js"></script>
  <script src="resources/webxr_test_constants.js"></script>
  <script>

    let makeSpaceTest = (space_type) => {
      return (session, fakeDeviceController, t) => {
        return session.requestReferenceSpace(space_type).then( (referenceSpace) => {
          t.step(() => {
            assert_true(referenceSpace instanceof XRReferenceSpace,
              "reference space is not correct type.");
          });
        });
      };
    };

    let makeInvalidSpaceTest = (space_type) => {
      return (session, fakeDeviceController, t) => {
          return  promise_rejects_dom(t, "NotSupportedError",
                                  session.requestReferenceSpace(space_type),
                                  "requestReferenceSpace('" + space_type + "')");
      };
    };

    let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;

    // Test that reference spaces matching default features work.
    xr_session_promise_test(
        "Non-immersive session supports viewer space by default",
        makeSpaceTest('viewer'), fakeDeviceInitParams, 'inline', {});
    xr_session_promise_test(
        "Immersive session supports viewer space by default",
        makeSpaceTest('viewer'), fakeDeviceInitParams, 'immersive-vr', {});
    xr_session_promise_test(
        "Immersive session supports local space by default",
        makeSpaceTest('local'), fakeDeviceInitParams, 'immersive-vr', {});

    // Test that session-appropriate non-default reference spaces work when requested
    xr_session_promise_test(
        "Non-immersive session supports local space when required",
        makeSpaceTest('local'), fakeDeviceInitParams, 'inline',
        {requiredFeatures: ['local']});
    xr_session_promise_test(
        "Non-immersive session supports local space when optional",
        makeSpaceTest('local'), fakeDeviceInitParams, 'inline',
        {optionalFeatures: ['local']});
    xr_session_promise_test(
        "Non-immersive session supports local-floor space when required",
        makeSpaceTest('local-floor'), fakeDeviceInitParams, 'inline',
        {requiredFeatures: ['local-floor']});
    xr_session_promise_test(
        "Immersive session supports local-floor space when required",
        makeSpaceTest('local-floor'), fakeDeviceInitParams, 'immersive-vr',
        {requiredFeatures: ['local-floor']});
    xr_session_promise_test(
        "Immersive session supports local-floor space when optional",
        makeSpaceTest('local-floor'), fakeDeviceInitParams, 'immersive-vr',
        {optionalFeatures: ['local-floor']});

    // Test that inline space can't request 'bounded-floor' or 'unbounded'
    xr_session_promise_test(
        "Non-immersive session rejects bounded-floor space even when requested",
        makeInvalidSpaceTest('bounded-floor'), fakeDeviceInitParams, 'inline',
        {optionalFeatures: ['bounded-floor']});
    xr_session_promise_test(
       "Non-immersive session rejects unbounded space even when requested",
        makeInvalidSpaceTest('unbounded'), fakeDeviceInitParams, 'inline',
        {optionalFeatures: ['unbounded']});

    // Test that reference spaces that aren't default features are rejected
    // when not requested as a feature.
    xr_session_promise_test(
       "Non-immersive session rejects local space if not requested",
        makeInvalidSpaceTest('local'), fakeDeviceInitParams, 'inline', {});
    xr_session_promise_test(
       "Immersive session rejects local-floor space if not requested",
        makeInvalidSpaceTest('local-floor'), fakeDeviceInitParams, 'immersive-vr', {});
  </script>
</body>