tor-browser

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

gl-enable-enum-test.html (4405B)


      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>WebGL gl.ENABLE enums Conformance Tests</title>
     12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
     13 <script src="../../js/desktop-gl-constants.js"></script>
     14 <script src="../../js/js-test-pre.js"></script>
     15 <script src="../../js/webgl-test-utils.js"></script>
     16 </head>
     17 <body>
     18 <div id="description"></div>
     19 <div id="console"></div>
     20 <script>
     21 "use strict";
     22 description("This test ensures WebGL implementations allow OpenGL ES 2.0 features to be turned on but not non OpenGL ES 2.0 features.");
     23 
     24 var wtu = WebGLTestUtils;
     25 
     26 var invalidEnums = [
     27  'ALPHA_TEST',
     28  'AUTO_NORMAL',
     29  'CLIP_PLANE0',
     30  'CLIP_PLANE1',
     31  'COLOR_LOGIC_OP',
     32  'COLOR_MATERIAL',
     33  'COLOR_SUM',
     34  'COLOR_TABLE',
     35  //'CONVOLUTION_1D',
     36  //'CONVOLUTION_2D',
     37  'FOG',
     38  'HISTOGRAM',
     39  'INDEX_LOGIC_OP',
     40  'LIGHT0',
     41  'LIGHT1',
     42  'LIGHTING',
     43  'LINE_SMOOTH',
     44  'LINE_STIPPLE',
     45  'MAP1_COLOR_4',
     46  'MAP1_INDEX',
     47  'MAP1_NORMAL',
     48  'MAP1_TEXTURE_COORD_1',
     49  'MAP1_TEXTURE_COORD_2',
     50  'MAP1_TEXTURE_COORD_3',
     51  'MAP1_TEXTURE_COORD_4',
     52  'MAP1_VERTEX_3',
     53  'MAP1_VERTEX_4',
     54  'MAP2_COLOR_4',
     55  'MAP2_INDEX',
     56  'MAP2_NORMAL',
     57  'MAP2_TEXTURE_COORD_1',
     58  'MAP2_TEXTURE_COORD_2',
     59  'MAP2_TEXTURE_COORD_3',
     60  'MAP2_TEXTURE_COORD_4',
     61  'MAP2_VERTEX_3',
     62  'MAP2_VERTEX_4',
     63  'MINMAX',
     64  'MULTISAMPLE',
     65  'NORMALIZE',
     66  'POINT_SMOOTH',
     67  'POINT_SPRITE',
     68  'POLYGON_OFFSET_LINE',
     69  'POLYGON_OFFSET_POINT',
     70  'POLYGON_SMOOTH',
     71  'POLYGON_STIPPLE',
     72  'POST_COLOR_MATRIX_COLOR_TABLE',
     73  'POST_CONVOLUTION_COLOR_TABLE',
     74  'RESCALE_NORMAL',
     75  'SAMPLE_ALPHA_TO_ONE',
     76  //'SEPARABLE_2D',
     77  'TEXTURE_1D',
     78  'TEXTURE_2D',
     79  'TEXTURE_3D',
     80  'TEXTURE_CUBE_MAP',
     81  'TEXTURE_GEN_Q',
     82  'TEXTURE_GEN_R',
     83  'TEXTURE_GEN_S',
     84  'TEXTURE_GEN_T',
     85  'VERTEX_PROGRAM_POINT_SIZE',
     86  'VERTEX_PROGRAM_TWO_SIDE'
     87 ];
     88 var validEnums = [
     89  'BLEND',
     90  'CULL_FACE',
     91  'DEPTH_TEST',
     92  'DITHER',
     93  'POLYGON_OFFSET_FILL',
     94  'SAMPLE_ALPHA_TO_COVERAGE',
     95  'SAMPLE_COVERAGE',
     96  'SCISSOR_TEST',
     97  'STENCIL_TEST'
     98 ];
     99 
    100 var gl;
    101 
    102 function runNegativeTests() {
    103  debug("");
    104  debug("Running negative tests");
    105 
    106  gl = wtu.create3DContext();
    107  if (!gl) {
    108    testFailed("context does not exist");
    109    return;
    110  }
    111  testPassed("context exists");
    112 
    113  for (var ii = 0; ii < invalidEnums.length; ++ii) {
    114    var name = invalidEnums[ii];
    115    gl.enable(desktopGL[name]);
    116    wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
    117              "gl.enable must set INVALID_ENUM when passed GL_" + name );
    118  }
    119 }
    120 
    121 function runPositiveTestsWithParameters(params) {
    122  debug("");
    123  debug("Running positive tests with parameters: " + JSON.stringify(params));
    124 
    125  // Pass null for the canvas, to make sure we create a new context each time.
    126  var newgl = wtu.create3DContext(null, params);
    127  if (gl == newgl) {
    128    testFailed("got an old context");
    129    return;
    130  }
    131  gl = newgl;
    132  if (!gl) {
    133    testFailed("context does not exist");
    134    return;
    135  }
    136  testPassed("context exists");
    137 
    138  debug("Checking gl.ENABLE enums.");
    139 
    140  for (var ii = 0; ii < validEnums.length; ++ii) {
    141    var name = validEnums[ii];
    142    gl.enable(gl[name]);
    143    wtu.glErrorShouldBe(gl, gl.NO_ERROR,
    144              "gl.enable must succeed when passed gl." + name );
    145    shouldBe('gl.isEnabled(gl.' + name + ')', 'true');
    146    shouldBe('gl.getParameter(gl.' + name + ')', 'true');
    147    gl.disable(gl[name]);
    148    shouldBe('gl.isEnabled(gl.' + name + ')', 'false');
    149    shouldBe('gl.getParameter(gl.' + name + ')', 'false');
    150    wtu.glErrorShouldBe(gl, gl.NO_ERROR,
    151              "gl.isEnabled and gl.GetParameter must not set errors when passed GL_" + name );
    152  }
    153 
    154  wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
    155 }
    156 
    157 runNegativeTests();
    158 runPositiveTestsWithParameters({alpha: true, antialias: true, stencil: true, depth: true});
    159 runPositiveTestsWithParameters({alpha: false, antialias: true, stencil: true, depth: true});
    160 runPositiveTestsWithParameters({alpha: true, antialias: false, stencil: true, depth: true});
    161 runPositiveTestsWithParameters({alpha: true, antialias: true, stencil: false, depth: true});
    162 runPositiveTestsWithParameters({alpha: true, antialias: true, stencil: true, depth: false});
    163 
    164 debug("");
    165 var successfullyParsed = true;
    166 
    167 </script>
    168 <script src="../../js/js-test-post.js"></script>
    169 
    170 </body>
    171 </html>