browser/devtools/shadereditor/test/browser_webgl-actor-test-06.js

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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests that the highlight/unhighlight and blackbox/unblackbox operations on
     6  * program actors work as expected.
     7  */
     9 function ifWebGLSupported() {
    10   let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL);
    11   front.setup({ reload: true });
    13   let programActor = yield once(front, "program-linked");
    14   let vertexShader = yield programActor.getVertexShader();
    15   let fragmentShader = yield programActor.getFragmentShader();
    17   yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    18   yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    19   yield checkShaderSource("The shader sources are correct before highlighting.");
    20   ok(true, "The corner pixel colors are correct before highlighting.");
    22   yield programActor.highlight([0, 1, 0, 1]);
    23   yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    24   yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    25   yield checkShaderSource("The shader sources are preserved after highlighting.");
    26   ok(true, "The corner pixel colors are correct after highlighting.");
    28   yield programActor.unhighlight();
    29   yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    30   yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    31   yield checkShaderSource("The shader sources are correct after unhighlighting.");
    32   ok(true, "The corner pixel colors are correct after unhighlighting.");
    34   yield programActor.blackbox();
    35   yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    36   yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    37   yield checkShaderSource("The shader sources are preserved after blackboxing.");
    38   ok(true, "The corner pixel colors are correct after blackboxing.");
    40   yield programActor.unblackbox();
    41   yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    42   yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    43   yield checkShaderSource("The shader sources are correct after unblackboxing.");
    44   ok(true, "The corner pixel colors are correct after unblackboxing.");
    46   function checkShaderSource(aMessage) {
    47     return Task.spawn(function() {
    48       let newVertexShader = yield programActor.getVertexShader();
    49       let newFragmentShader = yield programActor.getFragmentShader();
    50       is(vertexShader, newVertexShader,
    51         "The same vertex shader actor was retrieved.");
    52       is(fragmentShader, newFragmentShader,
    53         "The same fragment shader actor was retrieved.");
    55       let vertSource = yield newVertexShader.getText();
    56       let fragSource = yield newFragmentShader.getText();
    57       ok(vertSource.contains("I'm special!") &&
    58          fragSource.contains("I'm also special!"), aMessage);
    59     });
    60   }
    62   yield removeTab(target.tab);
    63   finish();
    64 }

mercurial