Bug 1526594 [wpt PR 15119] - Support the 'identity' XRReferenceSpace, a=testonly
authorBrandon Jones <bajones@chromium.org>
Mon, 18 Feb 2019 19:24:50 +0000
changeset 461105 c50f4ffe22edbb61b9a4a7be454098d8ef068dc6
parent 461104 4b6b8922a59aeed995bb1af9fa180cd7baf74432
child 461106 db60e08e38e92b2cb23e0209007f123cda0e8e7a
push id112159
push userjames@hoppipolla.co.uk
push dateTue, 26 Feb 2019 12:08:48 +0000
treeherdermozilla-inbound@20be3ebad986 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1526594, 15119, 922164, 1436853, 629374
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526594 [wpt PR 15119] - Support the 'identity' XRReferenceSpace, a=testonly Automatic update from web-platform-tests Support the 'identity' XRReferenceSpace Bug: 922164 Change-Id: I185caf8617266ee30eec4b45d348873cf968477f Reviewed-on: https://chromium-review.googlesource.com/c/1436853 Reviewed-by: Klaus Weidner <klausw@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org> Cr-Commit-Position: refs/heads/master@{#629374} -- wpt-commits: 9fc797e6e5fb7d244dfb5b5125886c01f8cedf2b wpt-pr: 15119
testing/web-platform/tests/webxr/xrSession_identity_referenceSpace.https.html
testing/web-platform/tests/webxr/xrSession_requestReferenceSpace.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webxr/xrSession_identity_referenceSpace.https.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<body>
+  <script src=/resources/testharness.js></script>
+  <script src=/resources/testharnessreport.js></script>
+  <script src="resources/webxr_util.js"></script>
+  <canvas></canvas>
+
+  <script>
+
+    let immersiveTestName =
+      "Identity reference space provides correct poses for immersive sessions";
+    let inlineTestName =
+      "Identity reference space provides correct poses for inline sessions";
+
+    let fakeDeviceInitParams = { supportsImmersive: true };
+
+    let immersiveSessionOptions = { mode: 'immersive-vr' };
+    let inlineSessionOptions = { outputContext: getOutputContext() };
+
+    const identityMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
+
+    // Valid matrices for  when we don't care about specific values
+    const validPoseMatrix = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1];
+    const validProjectionMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
+    const validViewMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
+
+    let testFunction = function(session, fakeDeviceController, t) {
+      return session.requestReferenceSpace({ type: 'identity' })
+        .then((referenceSpace) => new Promise((resolve, reject) => {
+          let counter = 0;
+          function onFrame(time, xrFrame) {
+            session.requestAnimationFrame(onFrame);
+            if (counter == 0) {
+              t.step( () => {
+                // Expect to always get a pose, even if none has been supplied.
+                let pose = xrFrame.getViewerPose(referenceSpace);
+                assert_not_equals(pose, null);
+
+                let poseMatrix = pose.poseModelMatrix;
+                assert_not_equals(poseMatrix, null);
+
+                for(let i = 0; i < poseMatrix.length; i++) {
+                  assert_equals(poseMatrix[i], identityMatrix[i]);
+                }
+
+                fakeDeviceController.setXRPresentationFrameData(
+                  validPoseMatrix, [{
+                    eye:"left",
+                    projectionMatrix: validProjectionMatrix,
+                    viewMatrix: validViewMatrix
+                  }, {
+                    eye:"right",
+                    projectionMatrix: validProjectionMatrix,
+                    viewMatrix: validViewMatrix
+                  }]);
+              });
+            } else {
+              t.step( () => {
+                // Assert that the identity matrix is always given as the pose
+                // even when a valid pose is set by the device.
+                let pose = xrFrame.getViewerPose(referenceSpace);
+                assert_not_equals(pose, null);
+
+                let poseMatrix = pose.poseModelMatrix;
+                assert_not_equals(poseMatrix, null);
+
+                for(let i = 0; i < poseMatrix.length; i++) {
+                  assert_equals(poseMatrix[i], identityMatrix[i]);
+                }
+              });
+
+              // Finished.
+              resolve();
+            }
+            counter++;
+          }
+
+          session.requestAnimationFrame(onFrame);
+        }));
+    };
+
+    xr_session_promise_test(inlineTestName, testFunction,
+      fakeDeviceInitParams, inlineSessionOptions);
+    xr_session_promise_test(immersiveTestName, testFunction,
+      fakeDeviceInitParams, immersiveSessionOptions);
+
+  </script>
+</body>
--- a/testing/web-platform/tests/webxr/xrSession_requestReferenceSpace.https.html
+++ b/testing/web-platform/tests/webxr/xrSession_requestReferenceSpace.https.html
@@ -16,16 +16,24 @@
     let immersiveSessionOptions = { mode: 'immersive-vr' };
     let nonImmersiveSessionOptions = { outputContext: getOutputContext() };
 
     let testFunction = function(session, fakeDeviceController, t) {
       return promise_rejects(t, new TypeError(), session.requestReferenceSpace({ type: "foo" }))
         .then(() => promise_rejects(t, "NotSupportedError", session.requestReferenceSpace({ type: "stationary" })))
         .then(() => promise_rejects(t, new TypeError(), session.requestReferenceSpace({ type: "stationary", subtype: "bar" })))
         .then(() => Promise.all([
+        session.requestReferenceSpace({ type: "identity" }).then( (referenceSpace) => {
+            t.step(() => {
+              assert_true(referenceSpace instanceof XRSpace,
+                "identity reference space is not correct type.");
+              assert_true(referenceSpace instanceof XRReferenceSpace,
+                "identity reference space is not correct type.");
+            });
+          }),
           session.requestReferenceSpace({ type: "stationary", subtype: "position-disabled" }).then( (referenceSpace) => {
             t.step(() => {
               assert_true(referenceSpace instanceof XRSpace,
                 "position-disabled stationary reference space is not correct type.");
               assert_true(referenceSpace instanceof XRReferenceSpace,
                 "position-disabled stationary reference space is not correct type.");
               assert_true(referenceSpace instanceof XRStationaryReferenceSpace,
                 "position-disabled stationary reference space is not correct type.");