summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrPose_transform_sameObject.https.html
blob: 9ea07fcd3bf223df7aa8b7e5959a6721e43d17b5 (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
<!DOCTYPE html>
<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 testName = "XRPose.transform meets [SameObject] requirement";

let testFunction = function(session, fakeDeviceController, t) {
  return new Promise((resolve) => {
    let input_source = fakeDeviceController.simulateInputSourceConnection({
      handedness: "right",
      targetRayMode: "tracked-pointer",
      pointerOrigin: VALID_POINTER_TRANSFORM,
      gripOrigin: VALID_GRIP_TRANSFORM,
      profiles: []
    });

    session.requestReferenceSpace('local').then((referenceSpace) => {
      requestSkipAnimationFrame(session, (time, xrFrame) => {
        let source = session.inputSources[0];
        let input_pose = xrFrame.getPose(source.targetRaySpace, referenceSpace);

        // Make sure that the transform attribute is the same object each time
        // we access it. This verifies that the XRPose does *not* do something
        // spec-noncompliant such as creating and returning a new
        // XRRigidTransform object each time the attribute is accessed.
        let transform = input_pose.transform;
        t.step(() => {
          assert_equals(transform, input_pose.transform,
            "XRPose.transform returns the same object.");
        });
        resolve();
      });
    });
  });
};

xr_session_promise_test(
  testName, testFunction, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr');
</script>