content/canvas/test/reftest/webgl-hanging-fb-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-hanging-fb-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 +/* Hanging Framebuffer Test
    1.12 + *
    1.13 + * Clear the canvas to green, but create and bind a new framebuffer
    1.14 + * before returning. This will fail if we blindly read from the bound
    1.15 + * framebuffer, instead of binding to the screen and reading from that.
    1.16 + *
    1.17 + * How failure looks isn't well defined, since this is an empty framebuffer,
    1.18 + * thus is incomplete, and should cause errors if it's read from.
    1.19 + */
    1.20 +
    1.21 +"use strict";
    1.22 +
    1.23 +function renderGL(gl) {
    1.24 +  gl.clearColor(0.0, 1.0, 0.0, 1.0);
    1.25 +  gl.clear(gl.COLOR_BUFFER_BIT);
    1.26 +
    1.27 +  var fb = gl.createFramebuffer();
    1.28 +  gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
    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 +  var gl = initGL(canvas);
    1.42 +
    1.43 +  if (gl)
    1.44 +    renderGL(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="256" height="256"></canvas>
    1.59 +</body>
    1.60 +
    1.61 +</html>

mercurial