|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests target navigations are handled correctly in the UI. |
|
6 */ |
|
7 |
|
8 function ifWebGLSupported() { |
|
9 let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL); |
|
10 let { gFront, $, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; |
|
11 |
|
12 reload(target); |
|
13 yield promise.all([ |
|
14 once(gFront, "program-linked"), |
|
15 once(panel.panelWin, EVENTS.SOURCES_SHOWN) |
|
16 ]); |
|
17 |
|
18 is($("#reload-notice").hidden, true, |
|
19 "The 'reload this page' notice should be hidden after linking."); |
|
20 is($("#waiting-notice").hidden, true, |
|
21 "The 'waiting for a WebGL context' notice should be visible after linking."); |
|
22 is($("#content").hidden, false, |
|
23 "The tool's content should not be hidden anymore."); |
|
24 |
|
25 is(ShadersListView.itemCount, 1, |
|
26 "The shaders list contains one entry."); |
|
27 is(ShadersListView.selectedItem, ShadersListView.items[0], |
|
28 "The shaders list has a correct item selected."); |
|
29 is(ShadersListView.selectedIndex, 0, |
|
30 "The shaders list has a correct index selected."); |
|
31 |
|
32 let vsEditor = yield ShadersEditorsView._getEditor("vs"); |
|
33 let fsEditor = yield ShadersEditorsView._getEditor("fs"); |
|
34 |
|
35 is(vsEditor.getText().indexOf("gl_Position"), 170, |
|
36 "The vertex shader editor contains the correct text."); |
|
37 is(fsEditor.getText().indexOf("gl_FragColor"), 97, |
|
38 "The fragment shader editor contains the correct text."); |
|
39 |
|
40 let navigating = once(target, "will-navigate"); |
|
41 let navigated = once(target, "will-navigate"); |
|
42 navigate(target, "about:blank"); |
|
43 |
|
44 yield navigating; |
|
45 yield once(panel.panelWin, EVENTS.UI_RESET); |
|
46 |
|
47 is($("#reload-notice").hidden, true, |
|
48 "The 'reload this page' notice should be hidden while navigating."); |
|
49 is($("#waiting-notice").hidden, false, |
|
50 "The 'waiting for a WebGL context' notice should be visible while navigating."); |
|
51 is($("#content").hidden, true, |
|
52 "The tool's content should be hidden now that there's no WebGL content."); |
|
53 |
|
54 is(ShadersListView.itemCount, 0, |
|
55 "The shaders list should be empty."); |
|
56 is(ShadersListView.selectedItem, null, |
|
57 "The shaders list has no correct item."); |
|
58 is(ShadersListView.selectedIndex, -1, |
|
59 "The shaders list has a negative index."); |
|
60 |
|
61 yield ShadersEditorsView._getEditor("vs").then(() => { |
|
62 ok(false, "The promise for a vertex shader editor should be rejected."); |
|
63 }, () => { |
|
64 ok(true, "The vertex shader editors wasn't initialized."); |
|
65 }); |
|
66 |
|
67 yield ShadersEditorsView._getEditor("fs").then(() => { |
|
68 ok(false, "The promise for a fragment shader editor should be rejected."); |
|
69 }, () => { |
|
70 ok(true, "The fragment shader editors wasn't initialized."); |
|
71 }); |
|
72 |
|
73 yield navigated; |
|
74 |
|
75 is($("#reload-notice").hidden, true, |
|
76 "The 'reload this page' notice should still be hidden after navigating."); |
|
77 is($("#waiting-notice").hidden, false, |
|
78 "The 'waiting for a WebGL context' notice should still be visible after navigating."); |
|
79 is($("#content").hidden, true, |
|
80 "The tool's content should be still hidden since there's no WebGL content."); |
|
81 |
|
82 yield teardown(panel); |
|
83 finish(); |
|
84 } |