1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_editor-contextmenu.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Bug 731394: Test the debugger source editor default context menu. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.12 + 1.13 +function test() { 1.14 + let gTab, gDebuggee, gPanel, gDebugger; 1.15 + let gEditor, gSources, gContextMenu; 1.16 + 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + gEditor = gDebugger.DebuggerView.editor; 1.23 + gSources = gDebugger.DebuggerView.Sources; 1.24 + gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu"); 1.25 + 1.26 + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest).then(null, info); 1.27 + gDebuggee.firstCall(); 1.28 + }); 1.29 + 1.30 + function performTest() { 1.31 + is(gDebugger.gThreadClient.state, "paused", 1.32 + "Should only be getting stack frames while paused."); 1.33 + is(gSources.itemCount, 2, 1.34 + "Found the expected number of sources."); 1.35 + is(gEditor.getText().indexOf("debugger"), 172, 1.36 + "The correct source was loaded initially."); 1.37 + is(gSources.selectedValue, gSources.values[1], 1.38 + "The correct source is selected."); 1.39 + 1.40 + is(gEditor.getText().indexOf("\u263a"), 162, 1.41 + "Unicode characters are converted correctly."); 1.42 + 1.43 + ok(gContextMenu, 1.44 + "The source editor's context menupopup is available."); 1.45 + ok(gEditor.getOption("readOnly"), 1.46 + "The source editor is read only."); 1.47 + 1.48 + gEditor.focus(); 1.49 + gEditor.setSelection({ line: 1, ch: 0 }, { line: 1, ch: 10 }); 1.50 + 1.51 + once(gContextMenu, "popupshown").then(testContextMenu).then(null, info); 1.52 + gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false); 1.53 + } 1.54 + 1.55 + function testContextMenu() { 1.56 + let document = gDebugger.document; 1.57 + 1.58 + ok(document.getElementById("editMenuCommands"), 1.59 + "#editMenuCommands found."); 1.60 + ok(!document.getElementById("editMenuKeys"), 1.61 + "#editMenuKeys not found."); 1.62 + 1.63 + gContextMenu.hidePopup(); 1.64 + resumeDebuggerThenCloseAndFinish(gPanel); 1.65 + } 1.66 +}