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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/shadereditor/test/browser_webgl-actor-test-06.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests that the highlight/unhighlight and blackbox/unblackbox operations on
     1.9 + * program actors work as expected.
    1.10 + */
    1.11 +
    1.12 +function ifWebGLSupported() {
    1.13 +  let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL);
    1.14 +  front.setup({ reload: true });
    1.15 +
    1.16 +  let programActor = yield once(front, "program-linked");
    1.17 +  let vertexShader = yield programActor.getVertexShader();
    1.18 +  let fragmentShader = yield programActor.getFragmentShader();
    1.19 +
    1.20 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.21 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.22 +  yield checkShaderSource("The shader sources are correct before highlighting.");
    1.23 +  ok(true, "The corner pixel colors are correct before highlighting.");
    1.24 +
    1.25 +  yield programActor.highlight([0, 1, 0, 1]);
    1.26 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    1.27 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.28 +  yield checkShaderSource("The shader sources are preserved after highlighting.");
    1.29 +  ok(true, "The corner pixel colors are correct after highlighting.");
    1.30 +
    1.31 +  yield programActor.unhighlight();
    1.32 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.33 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.34 +  yield checkShaderSource("The shader sources are correct after unhighlighting.");
    1.35 +  ok(true, "The corner pixel colors are correct after unhighlighting.");
    1.36 +
    1.37 +  yield programActor.blackbox();
    1.38 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    1.39 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
    1.40 +  yield checkShaderSource("The shader sources are preserved after blackboxing.");
    1.41 +  ok(true, "The corner pixel colors are correct after blackboxing.");
    1.42 +
    1.43 +  yield programActor.unblackbox();
    1.44 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.45 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.46 +  yield checkShaderSource("The shader sources are correct after unblackboxing.");
    1.47 +  ok(true, "The corner pixel colors are correct after unblackboxing.");
    1.48 +
    1.49 +  function checkShaderSource(aMessage) {
    1.50 +    return Task.spawn(function() {
    1.51 +      let newVertexShader = yield programActor.getVertexShader();
    1.52 +      let newFragmentShader = yield programActor.getFragmentShader();
    1.53 +      is(vertexShader, newVertexShader,
    1.54 +        "The same vertex shader actor was retrieved.");
    1.55 +      is(fragmentShader, newFragmentShader,
    1.56 +        "The same fragment shader actor was retrieved.");
    1.57 +
    1.58 +      let vertSource = yield newVertexShader.getText();
    1.59 +      let fragSource = yield newFragmentShader.getText();
    1.60 +      ok(vertSource.contains("I'm special!") &&
    1.61 +         fragSource.contains("I'm also special!"), aMessage);
    1.62 +    });
    1.63 +  }
    1.64 +
    1.65 +  yield removeTab(target.tab);
    1.66 +  finish();
    1.67 +}

mercurial