browser/devtools/shadereditor/test/browser_se_shaders-edit-02.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.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Tests if compile or linkage errors are emitted when a shader source
michael@0 6 * gets malformed after being edited.
michael@0 7 */
michael@0 8
michael@0 9 function ifWebGLSupported() {
michael@0 10 let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL);
michael@0 11 let { gFront, EVENTS, ShadersEditorsView } = panel.panelWin;
michael@0 12
michael@0 13 reload(target);
michael@0 14 yield promise.all([
michael@0 15 once(gFront, "program-linked"),
michael@0 16 once(panel.panelWin, EVENTS.SOURCES_SHOWN)
michael@0 17 ]);
michael@0 18
michael@0 19 let vsEditor = yield ShadersEditorsView._getEditor("vs");
michael@0 20 let fsEditor = yield ShadersEditorsView._getEditor("fs");
michael@0 21
michael@0 22 vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 });
michael@0 23 let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 24
michael@0 25 ok(error,
michael@0 26 "The new vertex shader source was compiled with errors.");
michael@0 27 is(error.compile, "",
michael@0 28 "The compilation status should be empty.");
michael@0 29 isnot(error.link, "",
michael@0 30 "The linkage status should not be empty.");
michael@0 31 is(error.link.split("ERROR").length - 1, 2,
michael@0 32 "The linkage status contains two errors.");
michael@0 33 ok(error.link.contains("ERROR: 0:8: 'constructor'"),
michael@0 34 "A constructor error is contained in the linkage status.");
michael@0 35 ok(error.link.contains("ERROR: 0:8: 'assign'"),
michael@0 36 "An assignment error is contained in the linkage status.");
michael@0 37
michael@0 38 fsEditor.replaceText("vec4", { line: 2, ch: 14 }, { line: 2, ch: 18 });
michael@0 39 let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 40
michael@0 41 ok(error,
michael@0 42 "The new fragment shader source was compiled with errors.");
michael@0 43 is(error.compile, "",
michael@0 44 "The compilation status should be empty.");
michael@0 45 isnot(error.link, "",
michael@0 46 "The linkage status should not be empty.");
michael@0 47 is(error.link.split("ERROR").length - 1, 1,
michael@0 48 "The linkage status contains one error.");
michael@0 49 ok(error.link.contains("ERROR: 0:6: 'constructor'"),
michael@0 50 "A constructor error is contained in the linkage status.");
michael@0 51
michael@0 52 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
michael@0 53 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
michael@0 54
michael@0 55 vsEditor.replaceText("vec4", { line: 7, ch: 22 }, { line: 7, ch: 26 });
michael@0 56 let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 57 ok(!error, "The new vertex shader source was compiled successfully.");
michael@0 58
michael@0 59 fsEditor.replaceText("vec3", { line: 2, ch: 14 }, { line: 2, ch: 18 });
michael@0 60 let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 61 ok(!error, "The new fragment shader source was compiled successfully.");
michael@0 62
michael@0 63 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
michael@0 64 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
michael@0 65
michael@0 66 yield teardown(panel);
michael@0 67 finish();
michael@0 68 }

mercurial