browser/devtools/debugger/test/browser_dbg_editor-contextmenu.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial