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