content/canvas/test/reftest/webgl-color-test.html

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:7b73e6e62206
1 <!DOCTYPE html>
2 <html class="reftest-wait">
3 <head>
4 <meta charset="UTF-8">
5
6 <script type="text/javascript" src="webgl-utils.js"></script>
7 <script type="text/javascript">
8 /* Color Test
9 *
10 * Clear the four quadrants of the canvas as follows:
11 * +------+------+
12 * | red |green |
13 * | | |
14 * +------+------+
15 * | blue |white |
16 * | | |
17 * +------+------+
18 *
19 * This is for checking that we're getting the right colors when
20 * we ask for them. This combined with the Orientation test assure
21 * that we are getting the correct colors in the correct places.
22 */
23
24 "use strict";
25
26 function renderGL(gl) {
27 gl.enable(gl.SCISSOR_TEST);
28
29 gl.scissor(0, 128, 128, 128);
30 gl.clearColor(1.0, 0.0, 0.0, 1.0);
31 gl.clear(gl.COLOR_BUFFER_BIT);
32
33 gl.scissor(128, 128, 128, 128);
34 gl.clearColor(0.0, 1.0, 0.0, 1.0);
35 gl.clear(gl.COLOR_BUFFER_BIT);
36
37 gl.scissor(0, 0, 128, 128);
38 gl.clearColor(0.0, 0.0, 1.0, 1.0);
39 gl.clear(gl.COLOR_BUFFER_BIT);
40
41 gl.scissor(128, 0, 128, 128);
42 gl.clearColor(1.0, 1.0, 1.0, 1.0);
43 gl.clear(gl.COLOR_BUFFER_BIT);
44
45 gl.finish();
46 }
47
48 function renderFailure(canvas) {
49 // This will also trigger RAF for us.
50 var context = canvas.getContext("2d");
51 context.fillText('WebGL failed.', 64, 64);
52 }
53
54 function runTest() {
55 var canvas = document.getElementById("canvas");
56 var gl = initGL(canvas);
57
58 if (gl)
59 renderGL(gl);
60 else
61 renderFailure(canvas);
62
63 waitForComposite(testComplete);
64 }
65
66 function testComplete() {
67 document.documentElement.removeAttribute("class");
68 }
69 </script>
70 </head>
71
72 <body onload="rAF(runTest);">
73 <canvas id="canvas" width="256" height="256"></canvas>
74 </body>
75
76 </html>

mercurial