|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if blackboxing a program works properly. |
|
6 */ |
|
7 |
|
8 function ifWebGLSupported() { |
|
9 let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); |
|
10 let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; |
|
11 |
|
12 once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => { |
|
13 ok(false, "No shaders should be publicly compiled during this test."); |
|
14 }); |
|
15 |
|
16 reload(target); |
|
17 let [[firstProgramActor, secondProgramActor]] = yield promise.all([ |
|
18 getPrograms(gFront, 2), |
|
19 once(panel.panelWin, EVENTS.SOURCES_SHOWN) |
|
20 ]); |
|
21 |
|
22 let vsEditor = yield ShadersEditorsView._getEditor("vs"); |
|
23 let fsEditor = yield ShadersEditorsView._getEditor("fs"); |
|
24 |
|
25 vsEditor.once("change", () => { |
|
26 ok(false, "The vertex shader source was unexpectedly changed."); |
|
27 }); |
|
28 fsEditor.once("change", () => { |
|
29 ok(false, "The fragment shader source was unexpectedly changed."); |
|
30 }); |
|
31 once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => { |
|
32 ok(false, "No sources should be changed form this point onward."); |
|
33 }); |
|
34 |
|
35 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
36 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
37 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
38 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
39 |
|
40 ok(!ShadersListView.selectedAttachment.isBlackBoxed, |
|
41 "The first program should not be blackboxed yet."); |
|
42 is(getBlackBoxCheckbox(panel, 0).checked, true, |
|
43 "The first blackbox checkbox should be initially checked."); |
|
44 ok(!ShadersListView.attachments[1].isBlackBoxed, |
|
45 "The second program should not be blackboxed yet."); |
|
46 is(getBlackBoxCheckbox(panel, 1).checked, true, |
|
47 "The second blackbox checkbox should be initially checked."); |
|
48 |
|
49 getBlackBoxCheckbox(panel, 0).click(); |
|
50 |
|
51 ok(ShadersListView.selectedAttachment.isBlackBoxed, |
|
52 "The first program should now be blackboxed."); |
|
53 is(getBlackBoxCheckbox(panel, 0).checked, false, |
|
54 "The first blackbox checkbox should now be unchecked."); |
|
55 ok(!ShadersListView.attachments[1].isBlackBoxed, |
|
56 "The second program should still not be blackboxed."); |
|
57 is(getBlackBoxCheckbox(panel, 1).checked, true, |
|
58 "The second blackbox checkbox should still be checked."); |
|
59 |
|
60 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
61 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
62 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
63 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
64 ok(true, "The first program was correctly blackboxed."); |
|
65 |
|
66 getBlackBoxCheckbox(panel, 1).click(); |
|
67 |
|
68 ok(ShadersListView.selectedAttachment.isBlackBoxed, |
|
69 "The first program should still be blackboxed."); |
|
70 is(getBlackBoxCheckbox(panel, 0).checked, false, |
|
71 "The first blackbox checkbox should still be unchecked."); |
|
72 ok(ShadersListView.attachments[1].isBlackBoxed, |
|
73 "The second program should now be blackboxed."); |
|
74 is(getBlackBoxCheckbox(panel, 1).checked, false, |
|
75 "The second blackbox checkbox should now be unchecked."); |
|
76 |
|
77 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
78 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
79 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
80 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
81 ok(true, "The second program was correctly blackboxed."); |
|
82 |
|
83 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) }); |
|
84 |
|
85 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
86 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
87 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
88 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
89 ok(true, "Highlighting shouldn't work while blackboxed (1)."); |
|
90 |
|
91 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) }); |
|
92 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) }); |
|
93 |
|
94 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
95 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
96 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
97 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
98 ok(true, "Highlighting shouldn't work while blackboxed (2)."); |
|
99 |
|
100 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) }); |
|
101 |
|
102 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
103 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
104 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
105 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2"); |
|
106 ok(true, "Highlighting shouldn't work while blackboxed (3)."); |
|
107 |
|
108 getBlackBoxCheckbox(panel, 0).click(); |
|
109 getBlackBoxCheckbox(panel, 1).click(); |
|
110 |
|
111 ok(!ShadersListView.selectedAttachment.isBlackBoxed, |
|
112 "The first program should now be unblackboxed."); |
|
113 is(getBlackBoxCheckbox(panel, 0).checked, true, |
|
114 "The first blackbox checkbox should now be rechecked."); |
|
115 ok(!ShadersListView.attachments[1].isBlackBoxed, |
|
116 "The second program should now be unblackboxed."); |
|
117 is(getBlackBoxCheckbox(panel, 1).checked, true, |
|
118 "The second blackbox checkbox should now be rechecked."); |
|
119 |
|
120 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
121 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
122 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
123 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
124 ok(true, "The two programs were correctly unblackboxed."); |
|
125 |
|
126 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) }); |
|
127 |
|
128 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
129 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
130 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
131 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
132 ok(true, "The first program was correctly highlighted."); |
|
133 |
|
134 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) }); |
|
135 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) }); |
|
136 |
|
137 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
138 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); |
|
139 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
140 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); |
|
141 ok(true, "The second program was correctly highlighted."); |
|
142 |
|
143 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) }); |
|
144 |
|
145 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
146 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
147 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
148 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
149 ok(true, "The two programs were correctly unhighlighted."); |
|
150 |
|
151 yield teardown(panel); |
|
152 finish(); |
|
153 } |
|
154 |
|
155 function getItemLabel(aPanel, aIndex) { |
|
156 return aPanel.panelWin.document.querySelectorAll( |
|
157 ".side-menu-widget-item-contents")[aIndex]; |
|
158 } |
|
159 |
|
160 function getBlackBoxCheckbox(aPanel, aIndex) { |
|
161 return aPanel.panelWin.document.querySelectorAll( |
|
162 ".side-menu-widget-item-checkbox")[aIndex]; |
|
163 } |
|
164 |
|
165 function once(aTarget, aEvent) { |
|
166 let deferred = promise.defer(); |
|
167 aTarget.once(aEvent, deferred.resolve); |
|
168 return deferred.promise; |
|
169 } |