|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if editing a vertex and a fragment shader would permanently store |
|
6 * their new source on the backend and reshow it in the frontend when required. |
|
7 */ |
|
8 |
|
9 function ifWebGLSupported() { |
|
10 let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); |
|
11 let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; |
|
12 |
|
13 reload(target); |
|
14 |
|
15 yield promise.all([ |
|
16 once(gFront, "program-linked"), |
|
17 once(gFront, "program-linked") |
|
18 ]); |
|
19 |
|
20 yield once(panel.panelWin, EVENTS.SOURCES_SHOWN) |
|
21 |
|
22 let vsEditor = yield ShadersEditorsView._getEditor("vs"); |
|
23 let fsEditor = yield ShadersEditorsView._getEditor("fs"); |
|
24 |
|
25 is(ShadersListView.selectedIndex, 0, |
|
26 "The first program is currently selected."); |
|
27 is(vsEditor.getText().indexOf("1);"), 136, |
|
28 "The vertex shader editor contains the correct initial text (1)."); |
|
29 is(fsEditor.getText().indexOf("1);"), 117, |
|
30 "The fragment shader editor contains the correct initial text (1)."); |
|
31 is(vsEditor.getText().indexOf("2.);"), -1, |
|
32 "The vertex shader editor contains the correct initial text (2)."); |
|
33 is(fsEditor.getText().indexOf(".0);"), -1, |
|
34 "The fragment shader editor contains the correct initial text (2)."); |
|
35 |
|
36 vsEditor.replaceText("2.", { line: 5, ch: 44 }, { line: 5, ch: 45 }); |
|
37 yield once(panel.panelWin, EVENTS.SHADER_COMPILED); |
|
38 |
|
39 fsEditor.replaceText(".0", { line: 5, ch: 35 }, { line: 5, ch: 37 }); |
|
40 yield once(panel.panelWin, EVENTS.SHADER_COMPILED); |
|
41 |
|
42 ok(true, "Vertex and fragment shaders were changed."); |
|
43 |
|
44 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
45 yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1"); |
|
46 yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1"); |
|
47 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
48 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
49 yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
50 yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
51 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
52 |
|
53 ok(true, "The vertex and fragment shaders were recompiled successfully."); |
|
54 |
|
55 EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target); |
|
56 yield once(panel.panelWin, EVENTS.SOURCES_SHOWN); |
|
57 |
|
58 is(ShadersListView.selectedIndex, 1, |
|
59 "The second program is currently selected."); |
|
60 is(vsEditor.getText().indexOf("1);"), 136, |
|
61 "The vertex shader editor contains the correct text (1)."); |
|
62 is(fsEditor.getText().indexOf("1);"), 117, |
|
63 "The fragment shader editor contains the correct text (1)."); |
|
64 is(vsEditor.getText().indexOf("2.);"), -1, |
|
65 "The vertex shader editor contains the correct text (2)."); |
|
66 is(fsEditor.getText().indexOf(".0);"), -1, |
|
67 "The fragment shader editor contains the correct text (2)."); |
|
68 |
|
69 EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[0].target); |
|
70 yield once(panel.panelWin, EVENTS.SOURCES_SHOWN); |
|
71 |
|
72 is(ShadersListView.selectedIndex, 0, |
|
73 "The first program is currently selected again."); |
|
74 is(vsEditor.getText().indexOf("1);"), -1, |
|
75 "The vertex shader editor contains the correct text (3)."); |
|
76 is(fsEditor.getText().indexOf("1);"), -1, |
|
77 "The fragment shader editor contains the correct text (3)."); |
|
78 is(vsEditor.getText().indexOf("2.);"), 136, |
|
79 "The vertex shader editor contains the correct text (4)."); |
|
80 is(fsEditor.getText().indexOf(".0);"), 116, |
|
81 "The fragment shader editor contains the correct text (4)."); |
|
82 |
|
83 yield teardown(panel); |
|
84 finish(); |
|
85 } |