browser/devtools/shadereditor/test/browser_se_shaders-edit-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/shadereditor/test/browser_se_shaders-edit-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     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 if compile or linkage errors are emitted when a shader source
     1.9 + * gets malformed after being edited.
    1.10 + */
    1.11 +
    1.12 +function ifWebGLSupported() {
    1.13 +  let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL);
    1.14 +  let { gFront, EVENTS, ShadersEditorsView } = panel.panelWin;
    1.15 +
    1.16 +  reload(target);
    1.17 +  yield promise.all([
    1.18 +    once(gFront, "program-linked"),
    1.19 +    once(panel.panelWin, EVENTS.SOURCES_SHOWN)
    1.20 +  ]);
    1.21 +
    1.22 +  let vsEditor = yield ShadersEditorsView._getEditor("vs");
    1.23 +  let fsEditor = yield ShadersEditorsView._getEditor("fs");
    1.24 +
    1.25 +  vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 });
    1.26 +  let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
    1.27 +
    1.28 +  ok(error,
    1.29 +    "The new vertex shader source was compiled with errors.");
    1.30 +  is(error.compile, "",
    1.31 +    "The compilation status should be empty.");
    1.32 +  isnot(error.link, "",
    1.33 +    "The linkage status should not be empty.");
    1.34 +  is(error.link.split("ERROR").length - 1, 2,
    1.35 +    "The linkage status contains two errors.");
    1.36 +  ok(error.link.contains("ERROR: 0:8: 'constructor'"),
    1.37 +    "A constructor error is contained in the linkage status.");
    1.38 +  ok(error.link.contains("ERROR: 0:8: 'assign'"),
    1.39 +    "An assignment error is contained in the linkage status.");
    1.40 +
    1.41 +  fsEditor.replaceText("vec4", { line: 2, ch: 14 }, { line: 2, ch: 18 });
    1.42 +  let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
    1.43 +
    1.44 +  ok(error,
    1.45 +    "The new fragment shader source was compiled with errors.");
    1.46 +  is(error.compile, "",
    1.47 +    "The compilation status should be empty.");
    1.48 +  isnot(error.link, "",
    1.49 +    "The linkage status should not be empty.");
    1.50 +  is(error.link.split("ERROR").length - 1, 1,
    1.51 +    "The linkage status contains one error.");
    1.52 +  ok(error.link.contains("ERROR: 0:6: 'constructor'"),
    1.53 +    "A constructor error is contained in the linkage status.");
    1.54 +
    1.55 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.56 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.57 +
    1.58 +  vsEditor.replaceText("vec4", { line: 7, ch: 22 }, { line: 7, ch: 26 });
    1.59 +  let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
    1.60 +  ok(!error, "The new vertex shader source was compiled successfully.");
    1.61 +
    1.62 +  fsEditor.replaceText("vec3", { line: 2, ch: 14 }, { line: 2, ch: 18 });
    1.63 +  let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
    1.64 +  ok(!error, "The new fragment shader source was compiled successfully.");
    1.65 +
    1.66 +  yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
    1.67 +  yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
    1.68 +
    1.69 +  yield teardown(panel);
    1.70 +  finish();
    1.71 +}

mercurial