tor-browser

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

long-expressions-should-not-crash.html (3578B)


      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>Driver Bug - long experssions should not crash</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 <script src="../../../js/glsl-conformance-test.js"></script>
     16 </head>
     17 <body>
     18 <canvas id="example" width="40" height="40"> </canvas>
     19 <div id="description"></div>
     20 <div id="console"></div>
     21 <script id="vshader" type="x-shader/x-vertex">
     22 void main(){
     23  gl_Position = vec4(0, 0, 0, 1);
     24 }
     25 </script>
     26 <script id="vshaderUniformTest" type="x-shader/x-vertex">
     27 uniform vec4 u_uniform;
     28 void main(){
     29  gl_Position =
     30      $(code)
     31      vec4(0, 0, 0, 1);
     32 }
     33 </script>
     34 <script id="fshader" type="x-shader/x-fragment">
     35 precision mediump float;
     36 void main()
     37 {
     38  gl_FragColor = vec4(0, 0, 0, 0);
     39 }
     40 </script>
     41 <script id="fshaderUniformTest" type="x-shader/x-fragment">
     42 precision mediump float;
     43 uniform vec4 u_uniform;
     44 void main()
     45 {
     46  gl_FragColor =
     47      $(code)
     48      vec4(0, 0, 0, 0);
     49 }
     50 </script>
     51 <script>
     52 "use strict";
     53 var wtu = WebGLTestUtils;
     54 var gl = wtu.create3DContext();
     55 
     56 var vUniformTestSource = wtu.getScript("vshaderUniformTest");
     57 var fUniformTestSource = wtu.getScript("fshaderUniformTest");
     58 
     59 var tests = [
     60 ];
     61 var counts = [
     62  { count:10,
     63    mustPass: true,
     64  },
     65  { count:100,
     66    mustPass: true,
     67  },
     68  { count: 1000,
     69    mustPass: false,
     70  },
     71  { count: 10000,
     72    mustPass: false,
     73  },
     74 ];
     75 var operatorSets = [
     76  ["+", "-", "/", "*"],
     77  ["+"],
     78  ["-"],
     79 ];
     80 counts.forEach(function(info) {
     81  operatorSets.forEach(function(operators) {
     82    var generateCode = function(numVars) {
     83      var codes = [];
     84      for (var uu = 0; uu < numVars; ++uu) {
     85        codes.push("u_uniform " + operators[uu % operators.length]);
     86      }
     87      return {
     88        code: codes.join("\n      "),
     89      };
     90    };
     91 
     92    var subs = generateCode(info.count);
     93    tests.push({
     94      vShaderId: "vshader",
     95      vShaderSuccess: true,
     96      fShaderSource: wtu.replaceParams(fUniformTestSource, subs),
     97      fShaderSuccess: true,
     98      linkSuccess: true,
     99      ignoreResults: !info.mustPass,
    100      passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in multiple lines",
    101    });
    102    tests.push({
    103      vShaderSource: wtu.replaceParams(vUniformTestSource, subs),
    104      vShaderSuccess: true,
    105      fShaderId: "fshader",
    106      fShaderSuccess: true,
    107      linkSuccess: true,
    108      ignoreResults: !info.mustPass,
    109      passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in multiple lines",
    110    });
    111    subs.code = subs.code.replace(/\n     /g, "")
    112    tests.push({
    113      vShaderId: "vshader",
    114      vShaderSuccess: true,
    115      fShaderSource: wtu.replaceParams(fUniformTestSource, subs),
    116      fShaderSuccess: true,
    117      linkSuccess: true,
    118      ignoreResults: !info.mustPass,
    119      passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in one line",
    120    });
    121    tests.push({
    122      vShaderSource: wtu.replaceParams(vUniformTestSource, subs),
    123      vShaderSuccess: true,
    124      fShaderId: "fshader",
    125      fShaderSuccess: true,
    126      linkSuccess: true,
    127      ignoreResults: !info.mustPass,
    128      passMsg: "shader with " + info.count + " [" + operators + "] operators in expression in one line",
    129    });
    130  });
    131 });
    132 GLSLConformanceTester.runTests(tests);
    133 </script>
    134 </body>
    135 </html>