browser/devtools/shadereditor/test/browser_se_editors-error-gutter.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 error indicators are shown in the editor's gutter and text area
michael@0 6 * when there's a shader compilation error.
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 [, vertError] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 24 checkHasVertFirstError(true, vertError);
michael@0 25 checkHasVertSecondError(false, vertError);
michael@0 26 info("Error marks added in the vertex shader editor.");
michael@0 27
michael@0 28 vsEditor.insertText(" ", { line: 1, ch: 0 });
michael@0 29 yield once(panel.panelWin, EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
michael@0 30 is(vsEditor.getText(1), " precision lowp float;", "Typed space.");
michael@0 31 checkHasVertFirstError(false, vertError);
michael@0 32 checkHasVertSecondError(false, vertError);
michael@0 33 info("Error marks removed while typing in the vertex shader editor.");
michael@0 34
michael@0 35 [, vertError] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 36 checkHasVertFirstError(true, vertError);
michael@0 37 checkHasVertSecondError(false, vertError);
michael@0 38 info("Error marks were re-added after recompiling the vertex shader.");
michael@0 39
michael@0 40 fsEditor.replaceText("vec4", { line: 2, ch: 14 }, { line: 2, ch: 18 });
michael@0 41 let [, fragError] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 42 checkHasVertFirstError(true, vertError);
michael@0 43 checkHasVertSecondError(false, vertError);
michael@0 44 checkHasFragError(true, fragError);
michael@0 45 info("Error marks added in the fragment shader editor.");
michael@0 46
michael@0 47 fsEditor.insertText(" ", { line: 1, ch: 0 });
michael@0 48 yield once(panel.panelWin, EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
michael@0 49 is(fsEditor.getText(1), " precision lowp float;", "Typed space.");
michael@0 50 checkHasVertFirstError(true, vertError);
michael@0 51 checkHasVertSecondError(false, vertError);
michael@0 52 checkHasFragError(false, fragError);
michael@0 53 info("Error marks removed while typing in the fragment shader editor.");
michael@0 54
michael@0 55 [, fragError] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 56 checkHasVertFirstError(true, vertError);
michael@0 57 checkHasVertSecondError(false, vertError);
michael@0 58 checkHasFragError(true, fragError);
michael@0 59 info("Error marks were re-added after recompiling the fragment shader.");
michael@0 60
michael@0 61 vsEditor.replaceText("2", { line: 3, ch: 19 }, { line: 3, ch: 20 });
michael@0 62 yield once(panel.panelWin, EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
michael@0 63 checkHasVertFirstError(false, vertError);
michael@0 64 checkHasVertSecondError(false, vertError);
michael@0 65 checkHasFragError(true, fragError);
michael@0 66 info("Error marks removed while typing in the vertex shader editor again.");
michael@0 67
michael@0 68 [, vertError] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 69 checkHasVertFirstError(true, vertError);
michael@0 70 checkHasVertSecondError(true, vertError);
michael@0 71 checkHasFragError(true, fragError);
michael@0 72 info("Error marks were re-added after recompiling the fragment shader again.");
michael@0 73
michael@0 74 yield teardown(panel);
michael@0 75 finish();
michael@0 76
michael@0 77 function checkHasVertFirstError(bool, error) {
michael@0 78 ok(error, "Vertex shader compiled with errors.");
michael@0 79 isnot(error.link, "", "The linkage status should not be empty.");
michael@0 80
michael@0 81 let line = 7;
michael@0 82 info("Checking first vertex shader error on line " + line + "...");
michael@0 83
michael@0 84 is(vsEditor.hasMarker(line, "errors", "error"), bool,
michael@0 85 "Error is " + (bool ? "" : "not ") + "shown in the editor's gutter.");
michael@0 86 is(vsEditor.hasLineClass(line, "error-line"), bool,
michael@0 87 "Error style is " + (bool ? "" : "not ") + "applied to the faulty line.");
michael@0 88
michael@0 89 let parsed = ShadersEditorsView._errors.vs;
michael@0 90 is(parsed.length >= 1, bool,
michael@0 91 "There's " + (bool ? ">= 1" : "< 1") + " parsed vertex shader error(s).");
michael@0 92
michael@0 93 if (bool) {
michael@0 94 is(parsed[0].line, line,
michael@0 95 "The correct line was parsed.");
michael@0 96 is(parsed[0].messages.length, 2,
michael@0 97 "There are 2 parsed messages.");
michael@0 98 ok(parsed[0].messages[0].contains("'constructor' : too many arguments"),
michael@0 99 "The correct first message was parsed.");
michael@0 100 ok(parsed[0].messages[1].contains("'assign' : cannot convert from"),
michael@0 101 "The correct second message was parsed.");
michael@0 102 }
michael@0 103 }
michael@0 104
michael@0 105 function checkHasVertSecondError(bool, error) {
michael@0 106 ok(error, "Vertex shader compiled with errors.");
michael@0 107 isnot(error.link, "", "The linkage status should not be empty.");
michael@0 108
michael@0 109 let line = 8;
michael@0 110 info("Checking second vertex shader error on line " + line + "...");
michael@0 111
michael@0 112 is(vsEditor.hasMarker(line, "errors", "error"), bool,
michael@0 113 "Error is " + (bool ? "" : "not ") + "shown in the editor's gutter.");
michael@0 114 is(vsEditor.hasLineClass(line, "error-line"), bool,
michael@0 115 "Error style is " + (bool ? "" : "not ") + "applied to the faulty line.");
michael@0 116
michael@0 117 let parsed = ShadersEditorsView._errors.vs;
michael@0 118 is(parsed.length >= 2, bool,
michael@0 119 "There's " + (bool ? ">= 2" : "< 2") + " parsed vertex shader error(s).");
michael@0 120
michael@0 121 if (bool) {
michael@0 122 is(parsed[1].line, line,
michael@0 123 "The correct line was parsed.");
michael@0 124 is(parsed[1].messages.length, 1,
michael@0 125 "There is 1 parsed message.");
michael@0 126 ok(parsed[1].messages[0].contains("'assign' : cannot convert from"),
michael@0 127 "The correct message was parsed.");
michael@0 128 }
michael@0 129 }
michael@0 130
michael@0 131 function checkHasFragError(bool, error) {
michael@0 132 ok(error, "Fragment shader compiled with errors.");
michael@0 133 isnot(error.link, "", "The linkage status should not be empty.");
michael@0 134
michael@0 135 let line = 5;
michael@0 136 info("Checking first vertex shader error on line " + line + "...");
michael@0 137
michael@0 138 is(fsEditor.hasMarker(line, "errors", "error"), bool,
michael@0 139 "Error is " + (bool ? "" : "not ") + "shown in the editor's gutter.");
michael@0 140 is(fsEditor.hasLineClass(line, "error-line"), bool,
michael@0 141 "Error style is " + (bool ? "" : "not ") + "applied to the faulty line.");
michael@0 142
michael@0 143 let parsed = ShadersEditorsView._errors.fs;
michael@0 144 is(parsed.length >= 1, bool,
michael@0 145 "There's " + (bool ? ">= 2" : "< 1") + " parsed fragment shader error(s).");
michael@0 146
michael@0 147 if (bool) {
michael@0 148 is(parsed[0].line, line,
michael@0 149 "The correct line was parsed.");
michael@0 150 is(parsed[0].messages.length, 1,
michael@0 151 "There is 1 parsed message.");
michael@0 152 ok(parsed[0].messages[0].contains("'constructor' : too many arguments"),
michael@0 153 "The correct message was parsed.");
michael@0 154 }
michael@0 155 }
michael@0 156 }

mercurial