2012-03-08 09:37:35 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bug 731394: test the debugger source editor default context menu.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
|
|
|
|
|
|
|
let gPane = null;
|
|
|
|
let gTab = null;
|
|
|
|
let gDebuggee = null;
|
|
|
|
let gDebugger = null;
|
|
|
|
|
|
|
|
function test()
|
|
|
|
{
|
|
|
|
let tempScope = {};
|
|
|
|
Cu.import("resource:///modules/source-editor.jsm", tempScope);
|
|
|
|
let SourceEditor = tempScope.SourceEditor;
|
|
|
|
|
|
|
|
let contextMenu = null;
|
2012-03-31 11:15:53 -07:00
|
|
|
let scriptShown = false;
|
|
|
|
let framesAdded = false;
|
2012-04-26 04:47:55 -07:00
|
|
|
let resumed = false;
|
|
|
|
let testStarted = false;
|
2012-03-08 09:37:35 -08:00
|
|
|
|
|
|
|
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
|
|
|
gTab = aTab;
|
|
|
|
gDebuggee = aDebuggee;
|
|
|
|
gPane = aPane;
|
2012-05-03 10:36:40 -07:00
|
|
|
gDebugger = gPane.contentWindow;
|
2012-04-26 04:47:55 -07:00
|
|
|
resumed = true;
|
2012-03-08 09:37:35 -08:00
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
2012-03-31 11:15:53 -07:00
|
|
|
framesAdded = true;
|
2012-04-26 04:47:55 -07:00
|
|
|
executeSoon(startTest);
|
2012-04-26 04:47:55 -07:00
|
|
|
});
|
2012-03-31 11:15:53 -07:00
|
|
|
|
2012-04-26 04:47:55 -07:00
|
|
|
executeSoon(function() {
|
|
|
|
gDebuggee.firstCall();
|
|
|
|
});
|
2012-05-02 13:20:02 -07:00
|
|
|
});
|
2012-04-26 04:47:55 -07:00
|
|
|
|
2012-04-26 04:47:55 -07:00
|
|
|
function onScriptShown(aEvent) {
|
|
|
|
scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
|
|
|
|
executeSoon(startTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:ScriptShown", onScriptShown);
|
|
|
|
|
|
|
|
function startTest()
|
2012-03-31 11:15:53 -07:00
|
|
|
{
|
2012-04-26 04:47:55 -07:00
|
|
|
if (scriptShown && framesAdded && resumed && !testStarted) {
|
|
|
|
testStarted = true;
|
|
|
|
window.removeEventListener("Debugger:ScriptShown", onScriptShown);
|
|
|
|
Services.tm.currentThread.dispatch({ run: performTest }, 0);
|
2012-03-31 11:15:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-26 04:47:55 -07:00
|
|
|
function performTest()
|
2012-03-08 09:37:35 -08:00
|
|
|
{
|
|
|
|
let scripts = gDebugger.DebuggerView.Scripts._scripts;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
2012-03-08 09:37:35 -08:00
|
|
|
"Should only be getting stack frames while paused.");
|
|
|
|
|
|
|
|
is(scripts.itemCount, 2, "Found the expected number of scripts.");
|
|
|
|
|
|
|
|
let editor = gDebugger.editor;
|
|
|
|
|
|
|
|
isnot(editor.getText().indexOf("debugger"), -1,
|
|
|
|
"The correct script was loaded initially.");
|
|
|
|
|
|
|
|
contextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
|
|
|
|
ok(contextMenu, "source editor context menupopup");
|
|
|
|
ok(editor.readOnly, "editor is read only");
|
|
|
|
|
|
|
|
editor.focus();
|
|
|
|
editor.setSelection(0, 10);
|
|
|
|
|
|
|
|
contextMenu.addEventListener("popupshown", function onPopupShown() {
|
|
|
|
contextMenu.removeEventListener("popupshown", onPopupShown, false);
|
|
|
|
executeSoon(testContextMenu);
|
|
|
|
}, false);
|
|
|
|
contextMenu.openPopup(editor.editorElement, "overlap", 0, 0, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testContextMenu()
|
|
|
|
{
|
|
|
|
let document = gDebugger.document;
|
|
|
|
|
|
|
|
ok(document.getElementById("editMenuCommands"),
|
|
|
|
"#editMenuCommands found");
|
|
|
|
ok(!document.getElementById("editMenuKeys"),
|
|
|
|
"#editMenuKeys not found");
|
|
|
|
ok(document.getElementById("sourceEditorCommands"),
|
|
|
|
"#sourceEditorCommands found");
|
|
|
|
ok(document.getElementById("sourceEditorKeys"),
|
|
|
|
"#sourceEditorKeys found");
|
|
|
|
|
|
|
|
// Map command ids to their expected disabled state.
|
|
|
|
let commands = {"se-cmd-undo": true, "se-cmd-redo": true,
|
|
|
|
"se-cmd-cut": true, "se-cmd-paste": true,
|
|
|
|
"se-cmd-delete": true, "cmd_findAgain": true,
|
|
|
|
"cmd_findPrevious": true, "cmd_find": false,
|
|
|
|
"cmd_gotoLine": false, "cmd_copy": false,
|
|
|
|
"se-cmd-selectAll": false};
|
|
|
|
for (let id in commands) {
|
|
|
|
let element = document.getElementById(id);
|
|
|
|
is(element.hasAttribute("disabled"), commands[id],
|
|
|
|
id + " hasAttribute('disabled') check");
|
|
|
|
}
|
|
|
|
|
|
|
|
executeSoon(function() {
|
|
|
|
contextMenu.hidePopup();
|
2012-07-18 07:21:57 -07:00
|
|
|
closeDebuggerAndFinish();
|
2012-03-08 09:37:35 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
|
|
|
});
|
|
|
|
}
|