Backed out changeset 713114c0331a (bug 1938707) by developer request CLOSED TREE
[gecko.git] / dom / canvas / test / webgl-mochitest / test_vertexattrib4f_update.html
blobe845b4a5943d74461af4a321f56f81a066fef177
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset='utf-8'>
5 <title>Bug 1426289 - vertexAttrib4f should actually update.</title>
6 <script src='/tests/SimpleTest/SimpleTest.js'></script>
7 <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
8 <script src='webgl-util.js'></script>
9 </head>
10 <body>
11 <script id='eVertSource' type='none'>
12 attribute vec4 aColor;
13 varying vec4 vColor;
15 void main() {
16 gl_PointSize = 64.0;
17 gl_Position = vec4(vec3(0.0), 1.0);
18 vColor = aColor;
20 </script>
21 <script id='eFragSource' type='none'>
22 precision mediump float;
23 varying vec4 vColor;
25 void main() {
26 gl_FragColor = vColor;
28 </script>
29 <script>
30 const canvas = document.createElement('canvas');
31 canvas.width = 1;
32 canvas.height = 1;
33 const gl = canvas.getContext('webgl');
35 const prog = WebGLUtil.linkProgramByIds(gl, eVertSource, eFragSource);
36 gl.useProgram(prog);
38 function getRgb() {
39 const data = new Uint32Array(1);
40 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(data.buffer));
41 return data[0] & 0xffffff;
44 gl.clearColor(0.0, 0.0, 0.0, 1.0);
45 gl.clear(gl.COLOR_BUFFER_BIT);
46 let was = getRgb();
47 ok(was == 0x000000, '0x'+was.toString(16));
49 gl.disableVertexAttribArray(prog.aColor);
51 gl.vertexAttrib4f(prog.aColor, 1, 0, 0, 1);
52 gl.drawArrays(gl.POINTS, 0, 1);
53 was = getRgb();
54 ok(was == 0x0000ff, '0x'+was.toString(16));
56 gl.vertexAttrib4f(prog.aColor, 0, 1, 0, 1);
57 gl.drawArrays(gl.POINTS, 0, 1);
58 was = getRgb();
59 ok(was == 0x00ff00, '0x'+was.toString(16));
60 </script>
61 </body>
62 </html>