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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE html>
     2 <html class="reftest-wait">
     3 <head>
     4 <meta charset="UTF-8">
     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  */
    24 "use strict";
    26 function renderGL(gl) {
    27   gl.enable(gl.SCISSOR_TEST);
    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);
    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);
    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);
    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);
    45   gl.finish();
    46 }
    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 }
    54 function runTest() {
    55   var canvas = document.getElementById("canvas");
    56   var gl = initGL(canvas);
    58   if (gl)
    59     renderGL(gl);
    60   else
    61     renderFailure(canvas);
    63   waitForComposite(testComplete);
    64 }
    66 function testComplete() {
    67   document.documentElement.removeAttribute("class");
    68 }
    69 </script>
    70 </head>
    72 <body onload="rAF(runTest);">
    73   <canvas id="canvas" width="256" height="256"></canvas>
    74 </body>
    76 </html>

mercurial