tor-browser

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

xrFrame_getLightEstimate_staleFrame.https.html (1515B)


      1 <!DOCTYPE html>
      2 <body>
      3  <script src=/resources/testharness.js></script>
      4  <script src=/resources/testharnessreport.js></script>
      5  <script src="../resources/webxr_util.js"></script>
      6  <script src="../resources/webxr_test_constants.js"></script>
      7 
      8  <script>
      9    let testName =  "Cannot get XrLightEstimate from stale frame";
     10    let testFunction = (session, controller, t) => new Promise((resolve) => {
     11      let lightProbe = null;
     12      let staleFrame = null;
     13 
     14      function onFrame(time, frame) {
     15        // Try to get the light estimate (even if it's null), it shouldn't throw.
     16        let estimate = frame.getLightEstimate(lightProbe);
     17        staleFrame = frame;
     18 
     19        t.step_timeout(afterFrame, 10);
     20      }
     21 
     22      function afterFrame() {
     23        t.step(() => {
     24          // Attempting to call a method on the frame outside the callback that
     25          // originally provided it should cause it to throw an exception.
     26          assert_throws_dom('InvalidStateError', () => staleFrame.getLightEstimate(lightProbe));
     27        });
     28 
     29        resolve();
     30      }
     31 
     32      // Request a default lightProbe
     33      let probeInit = {reflectionFormat: session.preferredReflectionFormat};
     34      session.requestLightProbe(probeInit).then((probe) => {
     35        lightProbe = probe;
     36        session.requestAnimationFrame(onFrame);
     37      });
     38    });
     39 
     40    xr_session_promise_test(
     41      testName,
     42      testFunction,
     43      IMMERSIVE_AR_DEVICE,
     44      'immersive-ar', {'requiredFeatures': ['light-estimation']});
     45 
     46  </script>
     47 </body>