|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if highlighting 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 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) }); |
|
41 |
|
42 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
43 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
44 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); |
|
45 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
46 ok(true, "The first program was correctly highlighted."); |
|
47 |
|
48 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) }); |
|
49 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) }); |
|
50 |
|
51 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
52 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); |
|
53 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
54 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); |
|
55 ok(true, "The second program was correctly highlighted."); |
|
56 |
|
57 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) }); |
|
58 |
|
59 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
60 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
61 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
62 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
63 ok(true, "The two programs were correctly unhighlighted."); |
|
64 |
|
65 ShadersListView._onProgramMouseEnter({ target: getBlackBoxCheckbox(panel, 0) }); |
|
66 |
|
67 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
68 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
69 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
70 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
71 ok(true, "The two programs were left unchanged after hovering a blackbox checkbox."); |
|
72 |
|
73 ShadersListView._onProgramMouseLeave({ target: getBlackBoxCheckbox(panel, 0) }); |
|
74 |
|
75 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
76 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
77 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); |
|
78 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); |
|
79 ok(true, "The two programs were left unchanged after unhovering a blackbox checkbox."); |
|
80 |
|
81 yield teardown(panel); |
|
82 finish(); |
|
83 } |
|
84 |
|
85 function getItemLabel(aPanel, aIndex) { |
|
86 return aPanel.panelWin.document.querySelectorAll( |
|
87 ".side-menu-widget-item-contents")[aIndex]; |
|
88 } |
|
89 |
|
90 function getBlackBoxCheckbox(aPanel, aIndex) { |
|
91 return aPanel.panelWin.document.querySelectorAll( |
|
92 ".side-menu-widget-item-checkbox")[aIndex]; |
|
93 } |