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

<!doctype html>
<!--
Used to test that the promise returned by WebXR's requestSession rejects if
the DON flow is canceled.
-->
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="../resources/webxr_e2e.css">
  </head>
  <body>
    <canvas id="webgl-canvas"></canvas>
    <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
    <script src="../resources/webxr_e2e.js"></script>
    <script src="../resources/webxr_boilerplate.js"></script>
    <script>
      function onImmersiveRequestWithDon() {
        console.log('Requesting immersive session');
        navigator.xr.requestSession('immersive-vr').then( (session) => {
          // Do nothing when the promise is automatically accepted.
          console.log('Promise accepted as expected');
          session.addEventListener("end", (event) => {
              // Wait for the session to be ended due to failed DON.
              done();
          });
        }, () => {
          assert_unreached("requestPresent promise rejected");
        });
      }
      webglCanvas.onclick = onImmersiveRequestWithDon;
    </script>
  </body>
</html>