2012-02-11 01:44:19 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure that updating the editor mode sets the right highlighting engine,
|
|
|
|
* and script URIs with extra query parameters also get the right engine.
|
|
|
|
*/
|
|
|
|
|
2012-02-29 09:20:02 -08:00
|
|
|
const TAB_URL = EXAMPLE_URL + "browser_dbg_update-editor-mode.html";
|
|
|
|
|
2012-02-11 01:44:19 -08:00
|
|
|
let tempScope = {};
|
|
|
|
Cu.import("resource:///modules/source-editor.jsm", tempScope);
|
|
|
|
let SourceEditor = tempScope.SourceEditor;
|
|
|
|
|
|
|
|
var gPane = null;
|
|
|
|
var gTab = null;
|
|
|
|
var gDebuggee = null;
|
|
|
|
var gDebugger = null;
|
|
|
|
var gScripts = null;
|
|
|
|
|
|
|
|
function test()
|
|
|
|
{
|
2012-04-05 03:47:26 -07:00
|
|
|
let scriptShown = false;
|
|
|
|
let framesAdded = false;
|
2012-04-26 04:47:55 -07:00
|
|
|
let testStarted = false;
|
|
|
|
let resumed = false;
|
2012-04-05 03:47:26 -07:00
|
|
|
|
2012-02-11 01:44:19 -08:00
|
|
|
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
|
|
|
gTab = aTab;
|
|
|
|
gDebuggee = aDebuggee;
|
|
|
|
gPane = aPane;
|
|
|
|
gDebugger = gPane.debuggerWindow;
|
2012-04-26 04:47:55 -07:00
|
|
|
resumed = true;
|
2012-02-11 01:44:19 -08:00
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
2012-04-05 03:47:26 -07:00
|
|
|
framesAdded = true;
|
2012-04-26 04:47:55 -07:00
|
|
|
executeSoon(startTest);
|
2012-04-05 03:47:26 -07:00
|
|
|
});
|
|
|
|
|
2012-04-26 04:47:55 -07:00
|
|
|
executeSoon(function() {
|
|
|
|
gDebuggee.firstCall();
|
|
|
|
});
|
2012-02-11 01:44:19 -08:00
|
|
|
});
|
2012-04-05 03:47:26 -07:00
|
|
|
|
2012-04-26 04:47:55 -07:00
|
|
|
function onScriptShown(aEvent) {
|
|
|
|
scriptShown = aEvent.detail.url.indexOf("test-editor-mode") != -1;
|
|
|
|
executeSoon(startTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:ScriptShown", onScriptShown);
|
|
|
|
|
|
|
|
function startTest()
|
2012-04-05 03:47:26 -07:00
|
|
|
{
|
2012-04-26 04:47:55 -07:00
|
|
|
if (scriptShown && framesAdded && resumed && !testStarted) {
|
|
|
|
window.removeEventListener("Debugger:ScriptShown", onScriptShown);
|
|
|
|
testStarted = true;
|
2012-04-05 03:47:26 -07:00
|
|
|
Services.tm.currentThread.dispatch({ run: testScriptsDisplay }, 0);
|
|
|
|
}
|
|
|
|
}
|
2012-02-11 01:44:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function testScriptsDisplay() {
|
2012-04-05 03:47:26 -07:00
|
|
|
gScripts = gDebugger.DebuggerView.Scripts._scripts;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
2012-04-05 03:47:26 -07:00
|
|
|
"Should only be getting stack frames while paused.");
|
|
|
|
|
|
|
|
is(gScripts.itemCount, 2, "Found the expected number of scripts.");
|
|
|
|
|
|
|
|
is(gDebugger.editor.getMode(), SourceEditor.MODES.HTML,
|
|
|
|
"Found the expected editor mode.");
|
|
|
|
|
|
|
|
ok(gDebugger.editor.getText().search(/debugger/) != -1,
|
|
|
|
"The correct script was loaded initially.");
|
|
|
|
|
|
|
|
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
|
|
|
|
let url = aEvent.detail.url;
|
|
|
|
if (url.indexOf("switching-01.js") != -1) {
|
|
|
|
window.removeEventListener(aEvent.type, _onEvent);
|
|
|
|
testSwitchPaused();
|
|
|
|
}
|
2012-02-11 01:44:19 -08:00
|
|
|
});
|
|
|
|
|
2012-04-05 03:47:26 -07:00
|
|
|
let url = gDebuggee.document.querySelector("script").src;
|
|
|
|
gDebugger.DebuggerView.Scripts.selectScript(url);
|
2012-02-11 01:44:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function testSwitchPaused()
|
|
|
|
{
|
|
|
|
ok(gDebugger.editor.getText().search(/debugger/) == -1,
|
|
|
|
"The second script is no longer displayed.");
|
|
|
|
|
|
|
|
ok(gDebugger.editor.getText().search(/firstCall/) != -1,
|
|
|
|
"The first script is displayed.");
|
|
|
|
|
|
|
|
is(gDebugger.editor.getMode(), SourceEditor.MODES.JAVASCRIPT,
|
|
|
|
"Found the expected editor mode.");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.resume(function() {
|
2012-03-06 00:22:17 -08:00
|
|
|
closeDebuggerAndFinish(gTab);
|
2012-02-11 01:44:19 -08:00
|
|
|
});
|
|
|
|
}
|
2012-03-06 00:22:17 -08:00
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
|
|
|
gScripts = null;
|
|
|
|
});
|