|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Bug 731394: Test the debugger source editor default context menu. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
|
9 |
|
10 function test() { |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 let gEditor, gSources, gContextMenu; |
|
13 |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 gEditor = gDebugger.DebuggerView.editor; |
|
20 gSources = gDebugger.DebuggerView.Sources; |
|
21 gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu"); |
|
22 |
|
23 waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest).then(null, info); |
|
24 gDebuggee.firstCall(); |
|
25 }); |
|
26 |
|
27 function performTest() { |
|
28 is(gDebugger.gThreadClient.state, "paused", |
|
29 "Should only be getting stack frames while paused."); |
|
30 is(gSources.itemCount, 2, |
|
31 "Found the expected number of sources."); |
|
32 is(gEditor.getText().indexOf("debugger"), 172, |
|
33 "The correct source was loaded initially."); |
|
34 is(gSources.selectedValue, gSources.values[1], |
|
35 "The correct source is selected."); |
|
36 |
|
37 is(gEditor.getText().indexOf("\u263a"), 162, |
|
38 "Unicode characters are converted correctly."); |
|
39 |
|
40 ok(gContextMenu, |
|
41 "The source editor's context menupopup is available."); |
|
42 ok(gEditor.getOption("readOnly"), |
|
43 "The source editor is read only."); |
|
44 |
|
45 gEditor.focus(); |
|
46 gEditor.setSelection({ line: 1, ch: 0 }, { line: 1, ch: 10 }); |
|
47 |
|
48 once(gContextMenu, "popupshown").then(testContextMenu).then(null, info); |
|
49 gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false); |
|
50 } |
|
51 |
|
52 function testContextMenu() { |
|
53 let document = gDebugger.document; |
|
54 |
|
55 ok(document.getElementById("editMenuCommands"), |
|
56 "#editMenuCommands found."); |
|
57 ok(!document.getElementById("editMenuKeys"), |
|
58 "#editMenuKeys not found."); |
|
59 |
|
60 gContextMenu.hidePopup(); |
|
61 resumeDebuggerThenCloseAndFinish(gPanel); |
|
62 } |
|
63 } |