tor-browser

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

zero-sized-canvas.html (1508B)


      1 <!--
      2 Copyright (c) 2020 The Khronos Group Inc.
      3 Use of this source code is governed by an MIT-style license that can be
      4 found in the LICENSE.txt file.
      5 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
     12 <script src="../../js/js-test-pre.js"></script>
     13 <script src="../../js/webgl-test-utils.js"></script>
     14 </head>
     15 <body>
     16 <div id="description"></div>
     17 <div id="console"></div>
     18 <script>
     19 "use strict";
     20 
     21 // Global declarations so that "shouldBe" can eval with them:
     22 let gl;
     23 
     24 (function() {
     25    description('Check that zero-sized canvases work with WebGL.');
     26 
     27    testZero();
     28 
     29    finishTest();
     30 })();
     31 
     32 function testZero() {
     33    const canvas = document.createElement('canvas');
     34    canvas.width = 0;
     35    canvas.height = 0;
     36    gl = WebGLTestUtils.create3DContext(canvas);
     37 
     38    expectTrue(gl, `Context creation with ${canvas.width}x${canvas.height} canvas should succeed.`);
     39    shouldBe('gl.drawingBufferWidth', '1');
     40    shouldBe('gl.drawingBufferHeight', '1');
     41    shouldBeFalse('gl.isContextLost()');
     42 
     43    const version = gl.getParameter(gl.VERSION);
     44    expectTrue(version && version.length, `getParameter() should return something.`);
     45 
     46    debug('canvas.width = 2');
     47    canvas.width = 2;
     48    shouldBe('gl.drawingBufferWidth', '2');
     49    shouldBeFalse('gl.isContextLost()');
     50 
     51    debug('canvas.width = 0');
     52    canvas.width = 0;
     53    shouldBe('gl.drawingBufferWidth', '1');
     54    shouldBeFalse('gl.isContextLost()');
     55 }
     56 
     57 </script>
     58 </body>
     59 </html>