2012-02-11 01:44:20 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure that selecting a stack frame loads the right script in the editor
|
|
|
|
* pane and highlights the proper line.
|
|
|
|
*/
|
|
|
|
|
2012-02-29 09:20:02 -08:00
|
|
|
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
|
|
|
|
2012-02-11 01:44:20 -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()
|
|
|
|
{
|
|
|
|
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-02-11 01:44:20 -08:00
|
|
|
|
|
|
|
testSelectLine();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSelectLine() {
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("scriptsadded", function() {
|
2012-02-11 01:44:20 -08:00
|
|
|
Services.tm.currentThread.dispatch({ run: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
gScripts = gDebugger.DebuggerView.Sources._container;
|
2012-02-11 01:44:20 -08:00
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
2012-02-11 01:44:20 -08:00
|
|
|
"Should only be getting stack frames while paused.");
|
|
|
|
|
|
|
|
is(gScripts.itemCount, 2, "Found the expected number of scripts.");
|
|
|
|
|
|
|
|
ok(gDebugger.editor.getText().search(/debugger/) != -1,
|
|
|
|
"The correct script was loaded initially.");
|
|
|
|
|
2012-02-15 06:12:27 -08:00
|
|
|
// Yield control back to the event loop so that the debugger has a
|
|
|
|
// chance to highlight the proper line.
|
|
|
|
executeSoon(function(){
|
|
|
|
// getCaretPosition is 0-based.
|
|
|
|
is(gDebugger.editor.getCaretPosition().line, 5,
|
|
|
|
"The correct line is selected.");
|
|
|
|
|
|
|
|
gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
|
|
|
|
function onChange() {
|
|
|
|
gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
|
|
|
|
onChange);
|
|
|
|
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.");
|
|
|
|
|
|
|
|
// Yield control back to the event loop so that the debugger has a
|
|
|
|
// chance to highlight the proper line.
|
|
|
|
executeSoon(function(){
|
|
|
|
// getCaretPosition is 0-based.
|
|
|
|
is(gDebugger.editor.getCaretPosition().line, 4,
|
|
|
|
"The correct line is selected.");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
gDebugger.DebuggerController.activeThread.resume(function() {
|
2012-05-31 03:01:13 -07:00
|
|
|
closeDebuggerAndFinish();
|
2012-02-15 06:12:27 -08:00
|
|
|
});
|
2012-02-11 01:44:20 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-03-07 10:46:00 -08:00
|
|
|
// Scroll all the way down to ensure stackframe-3 is visible.
|
|
|
|
let stackframes = gDebugger.document.getElementById("stackframes");
|
|
|
|
stackframes.scrollTop = stackframes.scrollHeight;
|
|
|
|
|
2012-02-15 06:12:27 -08:00
|
|
|
// Click the oldest stack frame.
|
2012-10-26 10:10:17 -07:00
|
|
|
let frames = gDebugger.DebuggerView.Stackframes._container._list;
|
2012-03-07 08:51:07 -08:00
|
|
|
is(frames.querySelectorAll(".dbg-stackframe").length, 4,
|
|
|
|
"Should have four frames.");
|
|
|
|
|
2012-02-15 06:12:27 -08:00
|
|
|
let element = gDebugger.document.getElementById("stackframe-3");
|
2012-03-07 08:51:07 -08:00
|
|
|
isnot(element, null, "Found the third stack frame.");
|
2012-02-15 06:12:27 -08:00
|
|
|
EventUtils.synthesizeMouseAtCenter(element, {}, gDebugger);
|
|
|
|
});
|
2012-02-11 01:44:20 -08:00
|
|
|
}}, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
gDebuggee.firstCall();
|
|
|
|
}
|
2012-03-06 00:22:17 -08:00
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
|
|
|
});
|