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

<!doctype html>
<!--
Tests that a non-immersive session's rAF stops firing when an immersive session
is active, but resumes afterwards.
-->
<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>
      let counter = 0;

      function stepBeforeImmersive() {
        onMagicWindowXRFrameCallback = function() {
          console.log('Got first inline frame');
          // Verify that we call a rAF once, then make sure any subsequent calls
          // are not done while there is an immersive session.
          onMagicWindowXRFrameCallback = function() {
            if (sessionInfos[sessionTypes.IMMERSIVE].currentSession !== null) {
              assert_unreached(
                  "Non-immersive rAF called during immersive session");
            }
          }
          finishJavaScriptStep();
        };
      }

      function stepDuringImmersive() {
        // Let the immersive session run for a bit so the non-immersive rAF
        // can fire if it's going to.
        onImmersiveXRFrameCallback = function() {
          console.log('Got immersive frame, frame count: ' + counter);
          if (counter < 10) {
            counter++;
            return;
          }

          onImmersiveXRFrameCallback = null;
          finishJavaScriptStep();
        };
      }

      function stepAfterImmersive() {
        // Make sure we fire at least once after exiting the immersive session
        onMagicWindowXRFrameCallback = function() {
          done();
        };
      }
    </script>
  </body>
</html>