chromium/chrome/test/data/xr/e2e_test_files/html/webxr_test_head_poses.html

<!doctype html>
<!--
Tests that WebXR head poses are properly surfaced.
-->
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="../resources/webxr_e2e.css">
  </head>
  <body>
    <canvas id="webgl-canvas"></canvas>
    <script src="../resources/webxr_e2e.js"></script>
    <script src="../resources/webxr_boilerplate.js"></script>
    <script>
      let expectedMatrix = null;

      function matricesApproximatelyEqual(a, b) {
        console.log('Given matrix: ' + JSON.stringify(a));
        console.log('Expected matrix: ' + JSON.stringify(b));
        if (a === null || b === null) {
          return false;
        }
        if (a.length != b.length) {
          return false;
        }
        for (let i = 0; i < a.length; ++i) {
          if (Math.abs(a[i] - b[i]) > 0.00001){
            return false;
          }
        }
        return true;
      }

      function stepWaitForMatchingPose(m) {
        expectedMatrix = m;
        onPoseCallback = function(pose) {
          console.log('Got pose');
          if (matricesApproximatelyEqual(
              pose.transform.matrix, expectedMatrix)) {
            onPoseCallback = null;
            finishJavaScriptStep();
          }
        }
      }
    </script>
  </body>
</html>