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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/reftest/webgl-resize-test.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     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 +/* Resize Test
    1.12 + *
    1.13 + * Create canvas of wrong size.
    1.14 + * Clear the canvas to red.
    1.15 + * Resize to correct size.
    1.16 + * Clear to green.
    1.17 + */
    1.18 +
    1.19 +"use strict";
    1.20 +
    1.21 +function render(gl) {
    1.22 +  gl.clearColor(1.0, 0.0, 0.0, 1.0);
    1.23 +  gl.clear(gl.COLOR_BUFFER_BIT);
    1.24 +
    1.25 +  gl.canvas.width = 256;
    1.26 +  gl.canvas.height = 256;
    1.27 +  gl.clearColor(0.0, 1.0, 0.0, 1.0);
    1.28 +  gl.clear(gl.COLOR_BUFFER_BIT);
    1.29 +
    1.30 +  gl.finish();
    1.31 +}
    1.32 +
    1.33 +function renderFailure(canvas) {
    1.34 +  // This will also trigger RAF for us.
    1.35 +  var context = canvas.getContext("2d");
    1.36 +  context.fillText('WebGL failed.', 64, 64);
    1.37 +}
    1.38 +
    1.39 +function runTest() {
    1.40 +  var canvas = document.getElementById("canvas");
    1.41 +
    1.42 +  var gl = initGL(canvas);
    1.43 +  if (gl)
    1.44 +    render(gl);
    1.45 +  else
    1.46 +    renderFailure(canvas);
    1.47 +
    1.48 +  waitForComposite(testComplete);
    1.49 +}
    1.50 +
    1.51 +function testComplete() {
    1.52 +  document.documentElement.removeAttribute("class");
    1.53 +}
    1.54 +</script>
    1.55 +</head>
    1.56 +
    1.57 +<body onload="rAF(runTest);">
    1.58 +  <canvas id="canvas" width="128" height="128" bgcolor='yellow'></canvas>
    1.59 +</body>
    1.60 +
    1.61 +</html>

mercurial