tor-browser

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

exclusive_requestFrame_nolayer.https.html (1982B)


      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 
      7 <script>
      8 let immersiveTestName = "XRSession requestAnimationFrame must fail if the session has "
      9  + "no baseLayer for immersive";
     10 
     11 let nonImmersiveTestName = "XRSession requestAnimationFrame must fail if the session has "
     12  + "no baseLayer for non immersive";
     13 
     14 let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
     15 
     16 let testFunction = (session, controller, t, sessionObjects) => new Promise((resolve, reject) => {
     17  // Clear the base layer that the boilerplate sets.  This ensures that the rAF
     18  // won't fire.  If the fire *does* fire, it will fail because the baseLayer
     19  // won't match the new baselayer we later create.
     20  session.updateRenderState({
     21    baseLayer: null
     22  });
     23  let gl = sessionObjects.gl;
     24 
     25  // Session must have a baseLayer or frame requests will be ignored.
     26  let webglLayer = new XRWebGLLayer(session, gl);
     27 
     28  function onEarlyFrame(time, vrFrame) {
     29    // We shouldn't be allowed to reach this callback with no baseLayer
     30    t.step(() => {
     31      assert_equals(session.renderState.baseLayer, webglLayer);
     32    });
     33    resolve();
     34  }
     35 
     36  // This callback shouldn't go through, since the session doesn't
     37  // have a baseLayer when this call is made.
     38  let handle = session.requestAnimationFrame(onEarlyFrame);
     39  // Should still give us a valid handle, though.
     40  assert_not_equals(handle, 0);
     41 
     42  // Wait for a bit and set the baseLayer.
     43  t.step_timeout(() => {
     44    // Once the base layer is set the previously registered callback should run.
     45    session.updateRenderState({
     46        baseLayer: webglLayer
     47    });
     48  }, 300);
     49 });
     50 
     51 xr_session_promise_test(
     52  immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr');
     53 xr_session_promise_test(
     54  nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline');
     55 
     56 </script>