tor-browser

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

webGLCanvasContext_create_xrcompatible.https.html (1793B)


      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  <script>
      8 
      9    function testNoDevice(t, gl) {
     10      assert_false(gl.getContextAttributes().xrCompatible);
     11      return promise_rejects_dom(t, "InvalidStateError", gl.makeXRCompatible());
     12    }
     13 
     14    xr_promise_test("Creating a webgl context with no device",
     15      testNoDevice, null, 'webgl');
     16 
     17    xr_promise_test("Creating a webgl2 context with no device",
     18      testNoDevice, null, 'webgl2');
     19 
     20    function testOffscreenCanvas(canvas, glContextType) {
     21      let gl = canvas.getContext('webgl');
     22 
     23      return gl.makeXRCompatible().then(() => {
     24        assert_true(gl.getContextAttributes().xrCompatible);
     25      });
     26    }
     27 
     28    function testXrCompatible(t, gl) {
     29      return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
     30        .then( (controller) => {
     31          return gl.makeXRCompatible();
     32        }).then( () => {
     33          assert_true(gl.getContextAttributes().xrCompatible);
     34 
     35          return testOffscreenCanvas(document.createElement('canvas'), 'webgl');
     36        }).then( () => {
     37          return testOffscreenCanvas(document.createElement('canvas'), 'webgl2');
     38        }).then( () => {
     39          return testOffscreenCanvas(new OffscreenCanvas(1, 1), 'webgl');
     40        }).then( () => {
     41          return testOffscreenCanvas(new OffscreenCanvas(1, 1), 'webgl2');
     42      });
     43    }
     44 
     45    xr_promise_test("An XR-compatible webgl context can be created",
     46      testXrCompatible, null, 'webgl');
     47 
     48    xr_promise_test("An XR-compatible webgl2 context can be created",
     49      testXrCompatible, null, 'webgl2');
     50 
     51  </script>
     52 </body>