Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / more / functions / vertexAttribBadArgs.html
blob67e44a5b872c9d5cfa72a3199e1446cb807b5f31
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">
15 var verts = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
16 var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0];
17 var texcoords = [0.0,0.0, 1.0,0.0, 0.0,1.0];
19 Tests.startUnit = function () {
20 var canvas = document.getElementById('gl');
21 var gl = wrapGLContext(getGLContext(canvas));
22 var prog = new Shader(gl, 'vert', 'frag');
23 prog.use();
24 var sh = prog.shader.program;
25 // log(gl.getShaderInfoLog(prog.shaders[1]));
26 var v = gl.getAttribLocation(sh, 'Vertex');
27 var n = gl.getAttribLocation(sh, 'Normal');
28 var t = gl.getAttribLocation(sh, 'Tex');
29 return [gl,prog,v,n,t];
32 Tests.setup = function(gl, prog, v,n,t) {
33 assert(0 == gl.getError());
34 return [gl, prog, v,n,t];
36 Tests.teardown = function(gl, prog, v,n,t) {
37 gl.disableVertexAttribArray(v);
38 gl.disableVertexAttribArray(n);
39 gl.disableVertexAttribArray(t);
42 Tests.endUnit = function(gl, prog, v,n,t) {
43 prog.destroy();
47 Tests.testVertexAttrib = function(gl, prog, v,n,t) {
48 var vbo = gl.createBuffer();
49 var vertsArr = new Float32Array(verts);
50 gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
51 gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
52 gl.enableVertexAttribArray(v);
53 gl.vertexAttribPointer(v, 3, gl.FLOAT, false, 0, 0);
54 assertFail("bad index",
55 function(){gl.vertexAttrib1f(-1, 1);});
56 assertFail("bad index (big negative)",
57 function(){gl.vertexAttrib1f(-69092342, 1);});
58 assertFail("bad index (big positive)",
59 function(){gl.vertexAttrib1f(58928938, 1);});
60 assertOk("array too large",
61 function(){gl.vertexAttrib1fv(v, [1,2,3,4,5]);});
62 assertFail("array too small",
63 function(){gl.vertexAttrib1fv(v, []);});
64 assertOk("draw",
65 function(){gl.drawArrays(gl.TRIANGLES, 0, 3);});
66 throwError(gl);
69 </script>
70 <script id="vert" type="x-shader/x-vertex">
71 attribute vec3 Vertex;
72 attribute vec3 Normal;
73 attribute vec2 Tex;
75 varying vec4 texCoord0;
76 void main()
78 gl_Position = vec4(Vertex * Normal, 1.0);
79 texCoord0 = vec4(Tex,0.0,0.0) + gl_Position;
81 </script>
82 <script id="frag" type="x-shader/x-fragment">
83 precision mediump float;
85 varying vec4 texCoord0;
86 void main()
88 vec4 c = texCoord0;
89 gl_FragColor = c;
91 </script>
94 <style>canvas{ position:absolute; }</style>
95 </head><body>
96 <canvas id="gl" width="1" height="1"></canvas>
97 </body></html>