Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!-- |
michael@0 | 2 | Copyright (c) 2011 The Chromium Authors. All rights reserved. |
michael@0 | 3 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | found in the LICENSE file. |
michael@0 | 5 | --> |
michael@0 | 6 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
michael@0 | 7 | "http://www.w3.org/TR/html4/loose.dtd"> |
michael@0 | 8 | <html> |
michael@0 | 9 | <head> |
michael@0 | 10 | <meta charset="utf-8"> |
michael@0 | 11 | <title>WebGL ouf of bounds uniform array access.</title> |
michael@0 | 12 | <link rel="stylesheet" href="../resources/js-test-style.css"/> |
michael@0 | 13 | <script src="../resources/js-test-pre.js"></script> |
michael@0 | 14 | <script src="../conformance/resources/webgl-test-utils.js"> </script> |
michael@0 | 15 | </head> |
michael@0 | 16 | <body style="background: #666;"> |
michael@0 | 17 | <div id="description"></div> |
michael@0 | 18 | <div id="console"></div> |
michael@0 | 19 | <div>elem mult: <span id="elemMultDisplay"></span></div> |
michael@0 | 20 | <input type="range" id="elemMult" value="4" min="0" max="2048" style="width: 100%;"/> |
michael@0 | 21 | <div>line width: <span id="lineWidthDisplay"></span></div> |
michael@0 | 22 | <input type="range" id="lineWidth" value="512" min="0" max="2540" style="width: 100%;"/> |
michael@0 | 23 | <canvas id="example" width="256" height="256" style="background: black;"> |
michael@0 | 24 | </canvas> |
michael@0 | 25 | <script id="vshader" type="x-shader/x-vertex"> |
michael@0 | 26 | attribute vec4 vPosition; |
michael@0 | 27 | varying vec4 v_color; |
michael@0 | 28 | uniform float lineWidth; |
michael@0 | 29 | uniform int elemMult; |
michael@0 | 30 | uniform vec4 someArray[2]; |
michael@0 | 31 | void main() |
michael@0 | 32 | { |
michael@0 | 33 | vec2 texcoord = vec2(vPosition.xy * 0.5 + vec2(0.5, 0.5)); |
michael@0 | 34 | int index = int(texcoord.x + texcoord.y * lineWidth) * elemMult; |
michael@0 | 35 | v_color = someArray[index]; |
michael@0 | 36 | gl_Position = vPosition; |
michael@0 | 37 | } |
michael@0 | 38 | </script> |
michael@0 | 39 | |
michael@0 | 40 | <script id="fshader" type="x-shader/x-fragment"> |
michael@0 | 41 | precision mediump float; |
michael@0 | 42 | varying vec4 v_color; |
michael@0 | 43 | void main() |
michael@0 | 44 | { |
michael@0 | 45 | gl_FragColor = v_color * vec4(1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0) + vec4(0,0,0,0.5); |
michael@0 | 46 | } |
michael@0 | 47 | </script> |
michael@0 | 48 | <script> |
michael@0 | 49 | window.onload = main; |
michael@0 | 50 | debug("Tests a WebGL program that accesses out of bounds uniform array elements"); |
michael@0 | 51 | |
michael@0 | 52 | function main() { |
michael@0 | 53 | var wtu = WebGLTestUtils; |
michael@0 | 54 | var gl = wtu.create3DContext("example"); |
michael@0 | 55 | var program = wtu.setupProgram( |
michael@0 | 56 | gl, |
michael@0 | 57 | ['vshader', 'fshader'], |
michael@0 | 58 | ['vPosition'], [0]); |
michael@0 | 59 | var gridRes = 255; |
michael@0 | 60 | wtu.setupQuad(gl, gridRes, 0); |
michael@0 | 61 | var lineWidthLoc = gl.getUniformLocation(program, "lineWidth"); |
michael@0 | 62 | var elemMultLoc = gl.getUniformLocation(program, "elemMult"); |
michael@0 | 63 | assertMsg(gl.getError() == gl.NO_ERROR, "Should be no errors from setup."); |
michael@0 | 64 | |
michael@0 | 65 | var lineWidth = 512; |
michael@0 | 66 | var lineWidthElem = document.getElementById("lineWidth"); |
michael@0 | 67 | var lineWidthDisplayElem = document.getElementById("lineWidthDisplay"); |
michael@0 | 68 | |
michael@0 | 69 | lineWidthElem.value = lineWidth; |
michael@0 | 70 | |
michael@0 | 71 | lineWidthElem.addEventListener('change', function(event) { |
michael@0 | 72 | //console.log(event.target.value); |
michael@0 | 73 | lineWidth = event.target.value; |
michael@0 | 74 | draw(); |
michael@0 | 75 | }, false); |
michael@0 | 76 | |
michael@0 | 77 | var elemMult = 4; |
michael@0 | 78 | var elemMultElem = document.getElementById("elemMult"); |
michael@0 | 79 | var elemMultDisplayElem = document.getElementById("elemMultDisplay"); |
michael@0 | 80 | |
michael@0 | 81 | elemMultElem.value = elemMult; |
michael@0 | 82 | |
michael@0 | 83 | elemMultElem.addEventListener('change', function(event) { |
michael@0 | 84 | //console.log(event.target.value); |
michael@0 | 85 | elemMult = event.target.value; |
michael@0 | 86 | draw(); |
michael@0 | 87 | }, false); |
michael@0 | 88 | |
michael@0 | 89 | draw(); |
michael@0 | 90 | |
michael@0 | 91 | function draw() { |
michael@0 | 92 | lineWidthDisplayElem.innerText = lineWidth; |
michael@0 | 93 | elemMultDisplayElem.innerText = elemMult; |
michael@0 | 94 | gl.uniform1f(lineWidthLoc, lineWidth); |
michael@0 | 95 | gl.uniform1i(elemMultLoc, elemMult); |
michael@0 | 96 | gl.drawElements(gl.TRIANGLES, gridRes * gridRes * 6, gl.UNSIGNED_SHORT, 0); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | successfullyParsed = true; |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | </script> |
michael@0 | 103 | </body> |
michael@0 | 104 | </html> |
michael@0 | 105 | |
michael@0 | 106 |