tor-browser

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

copyTexSubImage2DBadArgs.html (3367B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <!--
      6 Copyright (c) 2019 The Khronos Group Inc.
      7 Use of this source code is governed by an MIT-style license that can be
      8 found in the LICENSE.txt file.
      9 -->
     10 <link rel="stylesheet" type="text/css" href="../unit.css" />
     11 <script type="application/javascript" src="../unit.js"></script>
     12 <script type="application/javascript" src="../util.js"></script>
     13 <script type="application/javascript">
     14 
     15 Tests.startUnit = function () {
     16    var canvas = document.getElementById('gl');
     17    var gl = wrapGLContext(getGLContext(canvas));
     18    return [gl];
     19 }
     20 
     21 Tests.setup = function(gl) {
     22    var tex = gl.createTexture();
     23    gl.bindTexture(gl.TEXTURE_2D, tex);
     24    return [gl]
     25 }
     26 
     27 Tests.teardown = function(gl,tex) {
     28    gl.bindTexture(gl.TEXTURE_2D, null);
     29    gl.deleteTexture(tex);
     30 }
     31 
     32 Tests.testTexImage2D = function(gl) {
     33    gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0,0, 16,16, 0);
     34    assertGLError(gl, gl.INVALID_VALUE, "width > dst tex width", function(){
     35        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,0, 17,1);
     36    });
     37    assertGLError(gl, gl.INVALID_VALUE, "height > dst tex height", function(){
     38        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,0, 1,17);
     39    });
     40    // The spec says the source image dimensions can be out of range.
     41    assertOk("x > dst tex width", function(){
     42        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 16,0, 1,1);
     43    });
     44    assertOk("y > dst tex width", function(){
     45        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,16, 1,1);
     46    });
     47    assertOk("x < 0", function(){
     48        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, -1,0, 1,1);
     49    });
     50    assertOk("y < 0", function(){
     51        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,-1, 1,1);
     52    });
     53    assertGLError(gl, gl.INVALID_VALUE, "width < 0", function(){
     54        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,0, -1,1);
     55    });
     56    assertGLError(gl, gl.INVALID_VALUE, "height < 0", function(){
     57        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,0, 1,-1);
     58    });
     59    assertGLError(gl, gl.INVALID_VALUE, "xoffset < 0", function(){
     60        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, -1,0, 0,0, 16,16);
     61    });
     62    assertGLError(gl, gl.INVALID_VALUE, "yoffset < 0", function(){
     63        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,-1, 0,0, 16,16);
     64    });
     65    assertGLError(gl, gl.INVALID_VALUE, "dimension out of range", function(){
     66        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 4,0, 0,0, 16,16);
     67    });
     68    assertGLError(gl, gl.INVALID_VALUE, "dimension out of range", function(){
     69        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,4, 0,0, 16,16);
     70    });
     71    assertOk("x < 0 full width", function(){
     72        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, -1,0, 16,16);
     73    });
     74    assertOk("y < 0 full height", function(){
     75        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,-1, 16,16);
     76    });
     77    assertOk(function(){
     78        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0,0, 0,0, 16,16);
     79    });
     80    assertGLError(gl, gl.INVALID_ENUM, "bad target", function(){
     81        gl.copyTexSubImage2D(gl.FLOAT, 0, 0,0, 0,0, 16,16);
     82    });
     83    assertGLError(gl, gl.INVALID_VALUE, "", function(){
     84        gl.copyTexSubImage2D(gl.TEXTURE_2D, -1, 0,0, 0,0, 16,16);
     85    });
     86 }
     87 
     88 
     89 Tests.endUnit = function(gl) {
     90 }
     91 
     92 </script>
     93 <style>canvas{ position:absolute; }</style>
     94 </head><body>
     95 <canvas id="gl" width="16" height="16"></canvas>
     96 </body></html>