tor-browser

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

inactiveFrameTests.js (1591B)


      1 'use strict';
      2 const inactiveFrameTestFunction = function(session, controller, t, sessionObjects) {
      3  const isCpuOptimized = session.depthUsage === 'cpu-optimized';
      4  return session.requestReferenceSpace('viewer').then((viewerSpace) => {
      5    let callbacksKickedOff = false;
      6    let callbackCounter = 0;
      7 
      8    const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
      9 
     10    const rafCb = function(time, frame) {
     11      const pose = frame.getViewerPose(viewerSpace);
     12      for(const view of pose.views) {
     13        const callback = () => {
     14          t.step(() => {
     15            assert_throws_dom("InvalidStateError",
     16                              () => isCpuOptimized ? frame.getDepthInformation(view)
     17                                                    : glBinding.getDepthInformation(view),
     18                              "getDepthInformation() should throw when ran outside RAF");
     19            assert_throws_dom("InvalidStateError",
     20                              () => session.pauseDepthSensing(),
     21                              "pauseDepthSensing() should thrown when ran outside RAF");
     22            assert_throws_dom("InvalidStateError",
     23                              () => session.resumeDepthSensing(),
     24                              "resumeDepthSensing() should thrown when ran outside RAF");
     25          });
     26          callbackCounter--;
     27        }
     28 
     29        t.step_timeout(callback, 10);
     30        callbackCounter++;
     31      }
     32 
     33      callbacksKickedOff = true;
     34    };
     35 
     36    session.requestAnimationFrame(rafCb);
     37 
     38    return t.step_wait(() => callbacksKickedOff && (callbackCounter == 0));
     39  });
     40 };