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