tor-browser

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

test_noprog_draw.html (1686B)


      1 <!DOCTYPE HTML>
      2 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      3 
      4 <title>WebGL test: Drawing with a null program</title>
      5 
      6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
      8 <script src="driver-info.js"></script>
      9 <script src="webgl-util.js"></script>
     10 
     11 
     12 <script id="vs" type="x-shader/x-vertex">
     13 
     14 void main(void) {
     15  gl_PointSize = 16.0;
     16  gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     17 }
     18 
     19 </script>
     20 <script id="fs" type="x-shader/x-fragment">
     21 
     22 precision mediump float;
     23 
     24 void main(void) {
     25  gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
     26 }
     27 
     28 </script>
     29 <body>
     30 <canvas id="c" width="64" height="64"></canvas>
     31 <script>
     32 
     33 // Give ourselves a scope to return early from:
     34 (function() {
     35  var gl = c.getContext('webgl');
     36  if (!gl) {
     37    todo(false, 'WebGL is unavailable.');
     38    return;
     39  }
     40 
     41  gl.disable(gl.DEPTH_TEST);
     42 
     43  var prog   = WebGLUtil.createProgramByIds(gl, 'vs', 'fs');
     44  if (!prog) {
     45    ok(false, 'Program linking should succeed.');
     46    return;
     47  }
     48 
     49  function checkGLError(func, info, refValue) {
     50    if (!refValue)
     51      refValue = 0;
     52 
     53    var error = gl.getError();
     54    func(error == refValue,
     55         '[' + info + '] gl.getError should be 0x' + refValue.toString(16) +
     56                                        ', was 0x' + error.toString(16) + '.');
     57  }
     58 
     59  // Start drawing
     60  checkGLError(ok, 'after setup');
     61 
     62  gl.useProgram(prog);
     63  gl.drawArrays(gl.POINTS, 0, 1);
     64  checkGLError(ok, 'after non-null-program DrawArrays');
     65 
     66  gl.useProgram(null);
     67  gl.drawArrays(gl.POINTS, 0, 1);
     68  checkGLError(ok, 'after null-program DrawArrays', gl.INVALID_OPERATION);
     69 
     70  ok(true, 'Test complete.');
     71 })();
     72 
     73 </script>