tor-browser

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

texture-fakeblack.html (2994B)


      1 <!--
      2 Copyright (c) 2019 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 <title>Tests if fake black textures are corectly implemented on desktops</title>
     12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/>
     13 <script src="../../../js/js-test-pre.js"></script>
     14 <script src="../../../js/webgl-test-utils.js"></script>
     15 </head>
     16 <body>
     17 <canvas id="example" width="24" height="24"></canvas>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script>
     21 "use strict";
     22 
     23 function createTexture(gl,r,g,b,a) {
     24    // setup render target texture //
     25 
     26    var texture = gl.createTexture();
     27    gl.bindTexture(gl.TEXTURE_2D, texture);
     28    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
     29    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
     30    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
     31    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
     32    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 3, 3, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
     33    gl.bindTexture(gl.TEXTURE_2D, null);
     34 
     35    // setup framebuffer //
     36    var fbo = gl.createFramebuffer();
     37    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
     38    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
     39    gl.bindFramebuffer(gl.FRAMEBUFFER, null);
     40 
     41    // fill the framebuffer //
     42    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
     43    gl.clearColor(r, g, b, a);
     44    gl.clear(gl.COLOR_BUFFER_BIT);
     45    gl.bindFramebuffer(gl.FRAMEBUFFER, null);
     46 
     47    gl.deleteFramebuffer(fbo);
     48 
     49    return texture;
     50 }
     51 
     52 function init() {
     53    /*
     54     * This test has been written due to a bug found in firefox's code
     55     * and fixed in the following patch :
     56     * https://bugzilla.mozilla.org/show_bug.cgi?id=879952#c5
     57     */
     58    var wtu = WebGLTestUtils;
     59    description();
     60 
     61    var gl = wtu.create3DContext("example");
     62    var program = wtu.setupTexturedQuad(gl);
     63 
     64    var texture0 = createTexture(gl,1,0,0,1);
     65    var texture1 = createTexture(gl,0,1,0,1);
     66 
     67    gl.bindTexture(gl.TEXTURE_2D, texture0);
     68    gl.drawArrays(gl.TRIANGLES, 0, 6);
     69    wtu.checkCanvas(gl, [255, 0, 0, 255]);
     70 
     71    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
     72    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
     73    gl.drawArrays(gl.TRIANGLES, 0, 6);
     74    wtu.checkCanvas(gl, [0, 0, 0, 255]);
     75 
     76    gl.bindTexture(gl.TEXTURE_2D, texture1);
     77    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
     78    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
     79    gl.drawArrays(gl.TRIANGLES, 0, 6);
     80    wtu.checkCanvas(gl, [0, 255, 0, 255]);
     81 
     82    gl.bindTexture(gl.TEXTURE_2D, texture0);
     83    gl.drawArrays(gl.TRIANGLES, 0, 6);
     84    wtu.checkCanvas(gl, [0, 0, 0, 255]);
     85 }
     86 
     87 init();
     88 var successfullyParsed = true;
     89 </script>
     90 <script src="../../../js/js-test-post.js"></script>
     91 
     92 </body>
     93 </html>