browser/devtools/debugger/test/browser_dbg_blackboxing-05.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:95bbc920e529
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Test that a "this source is blackboxed" message is shown when necessary
6 * and can be properly dismissed.
7 */
8
9 const TAB_URL = EXAMPLE_URL + "doc_binary_search.html";
10
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gDeck;
13
14 function test() {
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
16 gTab = aTab;
17 gDebuggee = aDebuggee;
18 gPanel = aPanel;
19 gDebugger = gPanel.panelWin;
20 gDeck = gDebugger.document.getElementById("editor-deck");
21
22 waitForSourceShown(gPanel, ".coffee")
23 .then(testSourceEditorShown)
24 .then(toggleBlackBoxing.bind(null, gPanel))
25 .then(testBlackBoxMessageShown)
26 .then(clickStopBlackBoxingButton)
27 .then(testSourceEditorShownAgain)
28 .then(() => closeDebuggerAndFinish(gPanel))
29 .then(null, aError => {
30 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
31 });
32 });
33 }
34
35 function testSourceEditorShown() {
36 is(gDeck.selectedIndex, "0",
37 "The first item in the deck should be selected (the source editor).");
38 }
39
40 function testBlackBoxMessageShown() {
41 is(gDeck.selectedIndex, "1",
42 "The second item in the deck should be selected (the black box message).");
43 }
44
45 function clickStopBlackBoxingButton() {
46 let finished = waitForThreadEvents(gPanel, "blackboxchange");
47 getEditorBlackboxMessageButton().click();
48 return finished;
49 }
50
51 function testSourceEditorShownAgain() {
52 is(gDeck.selectedIndex, "0",
53 "The first item in the deck should be selected again (the source editor).");
54 }
55
56 function getEditorBlackboxMessageButton() {
57 return gDebugger.document.getElementById("black-boxed-message-button");
58 }
59
60 registerCleanupFunction(function() {
61 gTab = null;
62 gDebuggee = null;
63 gPanel = null;
64 gDebugger = null;
65 gDeck = null;
66 });

mercurial