tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

xrView_match.https.html (2992B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="resources/webxr_util.js"></script>
      5 <script src="resources/webxr_test_constants.js"></script>
      6 <script src="resources/webxr_test_asserts.js"></script>
      7 
      8 <script>
      9 
     10 let testName = "XRFrame contains the expected views";
     11 
     12 const fakeViews = [{
     13        eye:"left",
     14        projectionMatrix: VALID_PROJECTION_MATRIX,
     15        viewOffset: LEFT_OFFSET,
     16        resolution: VALID_RESOLUTION
     17    }, {
     18        eye:"right",
     19        projectionMatrix: VALID_PROJECTION_MATRIX,
     20        viewOffset: RIGHT_OFFSET,
     21        resolution: VALID_RESOLUTION
     22    },
     23 ];
     24 
     25 let fakeDeviceInitParams = {
     26    supportsImmersive: true,
     27    supportedModes: ["inline", "immersive-vr"],
     28    views: fakeViews,
     29    viewerOrigin: IDENTITY_TRANSFORM,
     30    supportedFeatures: ALL_FEATURES
     31 };
     32 
     33 let testFunction = function(session, fakeDeviceController, t) {
     34  return session.requestReferenceSpace('viewer').then(function(viewerSpace) {
     35    return session.requestReferenceSpace('local').then((referenceSpace) => new Promise((resolve) => {
     36      function onFrame(time, xrFrame) {
     37        let pose = xrFrame.getViewerPose(referenceSpace);
     38        assert_not_equals(pose, null);
     39        assert_not_equals(pose.views, null);
     40        assert_equals(pose.views.length, 2);
     41 
     42        {
     43          let pose2 = xrFrame.getPose(viewerSpace, referenceSpace);
     44          assert_not_equals(pose2, null);
     45 
     46          // This pose should have the same transform as the viewer pose, but without
     47          // the views array. It should be an XRPose instead of the XRViewerPose derived
     48          // class.
     49          assert_true(pose2 instanceof XRPose);
     50          assert_false(pose2 instanceof XRViewerPose);
     51          assert_not_equals(pose2.transform, null);
     52          assert_not_equals(pose2.transform.matrix, null);
     53          assert_matrix_approx_equals(pose.transform.matrix, pose2.transform.matrix);
     54        }
     55 
     56        // Ensure that two views are provided.
     57        let leftView = pose.views[0];
     58        let rightView = pose.views[1];
     59 
     60        // Ensure that the views are the right type.
     61        assert_true(leftView instanceof XRView);
     62        assert_true(rightView instanceof XRView);
     63 
     64        // Ensure that they have the expected eye enums.
     65        assert_equals(leftView.eye, "left");
     66        assert_equals(rightView.eye, "right");
     67 
     68        // Ensure they have the expected projection matrices.
     69        assert_not_equals(leftView.projectionMatrix, null);
     70        assert_not_equals(rightView.projectionMatrix, null);
     71 
     72        assert_matrix_approx_equals(leftView.projectionMatrix, VALID_PROJECTION_MATRIX);
     73        assert_matrix_approx_equals(rightView.projectionMatrix, VALID_PROJECTION_MATRIX);
     74 
     75        // Finished test.
     76        resolve();
     77      }
     78 
     79      session.requestAnimationFrame(onFrame);
     80    }));
     81  });
     82 };
     83 
     84 xr_session_promise_test(
     85  testName, testFunction, fakeDeviceInitParams, 'immersive-vr');
     86 
     87 </script>