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

<!doctype html>
<!--
Tests that window.requestAnimationFrame stops firing while in WebXR presentation
on Android.
-->
<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 numWindowRafs = 0;

      function stepVerifyBeforePresent() {
        window.requestAnimationFrame( () => {
          console.log('Got window frame before presentation');
          finishJavaScriptStep();
        });
      }

      function stepVerifyDuringPresent() {
        let handle = window.requestAnimationFrame( () => {
          numWindowRafs++;
          console.log(
              'Got window frame during immersive session, frame number: ' +
              numWindowRafs);
          // Even though we wait for setVSyncPaused to be called Java-side,
          // 1-2 frames might still get window rAFs due to the call to the
          // renderer being asynchronous.
          assert_less_than(numWindowRafs, 3);
        });
        window.setTimeout( () => {
          window.cancelAnimationFrame(handle);
          finishJavaScriptStep();
        }, 500);
      }

      function stepVerifyAfterPresent() {
        window.requestAnimationFrame( () => {
          console.log('Got window frame after presentation');
          done();
        });
      }
    </script>
  </body>
</html>