1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/reftest/webgl-color-test.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +<!DOCTYPE html> 1.5 +<html class="reftest-wait"> 1.6 +<head> 1.7 +<meta charset="UTF-8"> 1.8 + 1.9 +<script type="text/javascript" src="webgl-utils.js"></script> 1.10 +<script type="text/javascript"> 1.11 +/* Color Test 1.12 + * 1.13 + * Clear the four quadrants of the canvas as follows: 1.14 + * +------+------+ 1.15 + * | red |green | 1.16 + * | | | 1.17 + * +------+------+ 1.18 + * | blue |white | 1.19 + * | | | 1.20 + * +------+------+ 1.21 + * 1.22 + * This is for checking that we're getting the right colors when 1.23 + * we ask for them. This combined with the Orientation test assure 1.24 + * that we are getting the correct colors in the correct places. 1.25 + */ 1.26 + 1.27 +"use strict"; 1.28 + 1.29 +function renderGL(gl) { 1.30 + gl.enable(gl.SCISSOR_TEST); 1.31 + 1.32 + gl.scissor(0, 128, 128, 128); 1.33 + gl.clearColor(1.0, 0.0, 0.0, 1.0); 1.34 + gl.clear(gl.COLOR_BUFFER_BIT); 1.35 + 1.36 + gl.scissor(128, 128, 128, 128); 1.37 + gl.clearColor(0.0, 1.0, 0.0, 1.0); 1.38 + gl.clear(gl.COLOR_BUFFER_BIT); 1.39 + 1.40 + gl.scissor(0, 0, 128, 128); 1.41 + gl.clearColor(0.0, 0.0, 1.0, 1.0); 1.42 + gl.clear(gl.COLOR_BUFFER_BIT); 1.43 + 1.44 + gl.scissor(128, 0, 128, 128); 1.45 + gl.clearColor(1.0, 1.0, 1.0, 1.0); 1.46 + gl.clear(gl.COLOR_BUFFER_BIT); 1.47 + 1.48 + gl.finish(); 1.49 +} 1.50 + 1.51 +function renderFailure(canvas) { 1.52 + // This will also trigger RAF for us. 1.53 + var context = canvas.getContext("2d"); 1.54 + context.fillText('WebGL failed.', 64, 64); 1.55 +} 1.56 + 1.57 +function runTest() { 1.58 + var canvas = document.getElementById("canvas"); 1.59 + var gl = initGL(canvas); 1.60 + 1.61 + if (gl) 1.62 + renderGL(gl); 1.63 + else 1.64 + renderFailure(canvas); 1.65 + 1.66 + waitForComposite(testComplete); 1.67 +} 1.68 + 1.69 +function testComplete() { 1.70 + document.documentElement.removeAttribute("class"); 1.71 +} 1.72 +</script> 1.73 +</head> 1.74 + 1.75 +<body onload="rAF(runTest);"> 1.76 + <canvas id="canvas" width="256" height="256"></canvas> 1.77 +</body> 1.78 + 1.79 +</html>