mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-07 11:56:51 +00:00
Bug 876277 - Cleanup debugger stackframes tests, r=past
--HG-- rename : browser/devtools/debugger/test/browser_dbg_select-line.js => browser/devtools/debugger/test/browser_dbg_stack-06.js
This commit is contained in:
parent
b7c021dec1
commit
a3021547e7
@ -1,122 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebuggee = null;
|
||||
var gDebugger = null;
|
||||
var gSources = null;
|
||||
|
||||
function test()
|
||||
{
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
let testStarted = false;
|
||||
let resumed = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
resumed = true;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
framesAdded = true;
|
||||
executeSoon(startTest);
|
||||
});
|
||||
|
||||
executeSoon(function() {
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
});
|
||||
|
||||
function onScriptShown(aEvent) {
|
||||
scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
|
||||
executeSoon(startTest);
|
||||
}
|
||||
|
||||
function startTest()
|
||||
{
|
||||
if (scriptShown && framesAdded && resumed && !testStarted) {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
|
||||
testStarted = true;
|
||||
Services.tm.currentThread.dispatch({ run: testSelectLine }, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testSelectLine() {
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
|
||||
is(gSources.itemCount, 2, "Found the expected number of scripts.");
|
||||
|
||||
ok(gDebugger.editor.getText().search(/debugger/) != -1,
|
||||
"The correct script was loaded initially.");
|
||||
|
||||
// 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() {
|
||||
// Wait for the actual text to be shown.
|
||||
if (gDebugger.editor.getText() == gDebugger.L10N.getStr("loadingText")) {
|
||||
return;
|
||||
}
|
||||
// The requested source text has been shown, remove the event listener.
|
||||
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.");
|
||||
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
});
|
||||
|
||||
let frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
let childNodes = frames.childNodes;
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 4,
|
||||
"Should have two frames.");
|
||||
|
||||
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
|
||||
"All children should be frames.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
frames.querySelector("#stackframe-3"),
|
||||
gDebugger);
|
||||
});
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gSources = null;
|
||||
});
|
@ -1,54 +1,41 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that stackframes are added when debugger is paused.
|
||||
*/
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebuggee = null;
|
||||
var gDebugger = null;
|
||||
const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gFrames;
|
||||
|
||||
function test() {
|
||||
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gFrames = gDebugger.DebuggerView.StackFrames;
|
||||
|
||||
testSimpleCall();
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 14).then(performTest);
|
||||
gDebuggee.simpleCall();
|
||||
});
|
||||
}
|
||||
|
||||
function testSimpleCall() {
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
Services.tm.currentThread.dispatch({ run: function() {
|
||||
function performTest() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gFrames.itemCount, 1,
|
||||
"Should have only one frame.");
|
||||
|
||||
let frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
let childNodes = frames.childNodes;
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 1,
|
||||
"Should have only one frame.");
|
||||
|
||||
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
|
||||
"All children should be frames.");
|
||||
|
||||
gDebugger.DebuggerController.activeThread.resume(function() {
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
}}, 0);
|
||||
});
|
||||
|
||||
gDebuggee.simpleCall();
|
||||
resumeDebuggerThenCloseAndFinish(gPanel);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gFrames = null;
|
||||
});
|
||||
|
@ -1,86 +1,83 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that stackframes are added when debugger is paused in eval calls.
|
||||
*/
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebuggee = null;
|
||||
var gDebugger = null;
|
||||
const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gFrames;
|
||||
|
||||
function test() {
|
||||
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gFrames = gDebugger.DebuggerView.StackFrames;
|
||||
|
||||
testEvalCall();
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 18).then(performTest);
|
||||
gDebuggee.evalCall();
|
||||
});
|
||||
}
|
||||
|
||||
function testEvalCall() {
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
Services.tm.currentThread.dispatch({ run: function() {
|
||||
function performTest() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gFrames.itemCount, 2,
|
||||
"Should have two frames.");
|
||||
|
||||
let frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
let childNodes = frames.childNodes;
|
||||
is(gFrames.getItemAtIndex(0).value,
|
||||
"evalCall", "Oldest frame name should be correct.");
|
||||
is(gFrames.getItemAtIndex(0).description,
|
||||
TAB_URL, "Oldest frame url should be correct.");
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gFrames.getItemAtIndex(1).value,
|
||||
"(eval)", "Newest frame name should be correct.");
|
||||
is(gFrames.getItemAtIndex(1).description,
|
||||
TAB_URL, "Newest frame url should be correct.");
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 2,
|
||||
"Should have two frames.");
|
||||
is(gFrames.selectedIndex, 1,
|
||||
"Newest frame should be selected by default.");
|
||||
isnot(gFrames.selectedIndex, 0,
|
||||
"Oldest frame should not be selected.");
|
||||
|
||||
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
|
||||
"All children should be frames.");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gFrames.getItemAtIndex(0).target,
|
||||
gDebugger);
|
||||
|
||||
is(frames.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
|
||||
"(eval)", "Frame name should be (eval)");
|
||||
isnot(gFrames.selectedIndex, 1,
|
||||
"Newest frame should not be selected after click.");
|
||||
is(gFrames.selectedIndex, 0,
|
||||
"Oldest frame should be selected after click.");
|
||||
|
||||
ok(frames.querySelector("#stackframe-0").parentNode.hasAttribute("checked"),
|
||||
"First frame should be selected by default.");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gFrames.getItemAtIndex(1).target.querySelector(".dbg-stackframe-title"),
|
||||
gDebugger);
|
||||
|
||||
ok(!frames.querySelector("#stackframe-1").parentNode.hasAttribute("checked"),
|
||||
"Second frame should not be selected.");
|
||||
is(gFrames.selectedIndex, 1,
|
||||
"Newest frame should be selected after click inside the newest frame.");
|
||||
isnot(gFrames.selectedIndex, 0,
|
||||
"Oldest frame should not be selected after click inside the newest frame.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gFrames.getItemAtIndex(0).target.querySelector(".dbg-stackframe-details"),
|
||||
gDebugger);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
frames.querySelector("#stackframe-1"),
|
||||
gDebugger);
|
||||
isnot(gFrames.selectedIndex, 1,
|
||||
"Newest frame should not be selected after click inside the oldest frame.");
|
||||
is(gFrames.selectedIndex, 0,
|
||||
"Oldest frame should be selected after click inside the oldest frame.");
|
||||
|
||||
ok(!frames.querySelector("#stackframe-0").parentNode.hasAttribute("checked"),
|
||||
"First frame should not be selected after click.");
|
||||
|
||||
ok(frames.querySelector("#stackframe-1").parentNode.hasAttribute("checked"),
|
||||
"Second frame should be selected after click.");
|
||||
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
frames.querySelector("#stackframe-0 .dbg-stackframe-title"),
|
||||
gDebugger);
|
||||
|
||||
ok(frames.querySelector("#stackframe-0").parentNode.hasAttribute("checked"),
|
||||
"First frame should be selected after click inside the first frame.");
|
||||
|
||||
ok(!frames.querySelector("#stackframe-1").parentNode.hasAttribute("checked"),
|
||||
"Second frame should not be selected after click inside the first frame.");
|
||||
|
||||
|
||||
gDebugger.DebuggerController.activeThread.resume(function() {
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
}}, 0);
|
||||
});
|
||||
|
||||
gDebuggee.evalCall();
|
||||
resumeDebuggerThenCloseAndFinish(gPanel);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gFrames = null;
|
||||
});
|
||||
|
@ -1,71 +1,60 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that stackframes are scrollable.
|
||||
*/
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebuggee = null;
|
||||
var gDebugger = null;
|
||||
const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gFrames;
|
||||
|
||||
function test() {
|
||||
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gFrames = gDebugger.DebuggerView.StackFrames;
|
||||
|
||||
testRecurse();
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 26).then(performTest);
|
||||
|
||||
gDebuggee.gRecurseLimit = (gDebugger.gCallStackPageSize * 2) + 1;
|
||||
gDebuggee.recurse();
|
||||
});
|
||||
}
|
||||
|
||||
function testRecurse() {
|
||||
gDebuggee.gRecurseLimit = (gDebugger.gCallStackPageSize * 2) + 1;
|
||||
function performTest() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gFrames.itemCount, gDebugger.gCallStackPageSize,
|
||||
"Should have only the max limit of frames.");
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
Services.tm.currentThread.dispatch({ run: function() {
|
||||
gDebugger.gThreadClient.addOneTimeListener("framesadded", () => {
|
||||
is(gFrames.itemCount, gDebugger.gCallStackPageSize * 2,
|
||||
"Should now have twice the max limit of frames.");
|
||||
|
||||
let frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
let pageSize = gDebugger.gCallStackPageSize;
|
||||
let recurseLimit = gDebuggee.gRecurseLimit;
|
||||
let childNodes = frames.childNodes;
|
||||
gDebugger.gThreadClient.addOneTimeListener("framesadded", () => {
|
||||
is(gFrames.itemCount, gDebuggee.gRecurseLimit,
|
||||
"Should have reached the recurse limit.");
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, pageSize,
|
||||
"Should have the max limit of frames.");
|
||||
|
||||
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
|
||||
"All children should be frames.");
|
||||
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, pageSize * 2,
|
||||
"Should now have twice the max limit of frames.");
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, recurseLimit,
|
||||
"Should have reached the recurse limit.");
|
||||
|
||||
gDebugger.DebuggerController.activeThread.resume(function() {
|
||||
window.clearInterval(scrollingInterval);
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
});
|
||||
gDebugger.gThreadClient.resume(() => {
|
||||
window.clearInterval(scrollingIntervalId);
|
||||
closeDebuggerAndFinish(gPanel);
|
||||
});
|
||||
|
||||
let scrollingInterval = window.setInterval(function() {
|
||||
frames.scrollByIndex(-1);
|
||||
}, 100);
|
||||
}}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
gDebuggee.recurse();
|
||||
let scrollingIntervalId = window.setInterval(() => {
|
||||
gFrames.widget._list.scrollByIndex(-1);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gFrames = null;
|
||||
});
|
||||
|
@ -1,65 +1,48 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that stackframes are cleared after resume.
|
||||
*/
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebuggee = null;
|
||||
var gDebugger = null;
|
||||
const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gFrames;
|
||||
|
||||
function test() {
|
||||
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gFrames = gDebugger.DebuggerView.StackFrames;
|
||||
|
||||
testEvalCallResume();
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 18).then(performTest);
|
||||
gDebuggee.evalCall();
|
||||
});
|
||||
}
|
||||
|
||||
function testEvalCallResume() {
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
Services.tm.currentThread.dispatch({ run: function() {
|
||||
function performTest() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gFrames.itemCount, 2,
|
||||
"Should have two frames.");
|
||||
|
||||
let frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
let childNodes = frames.childNodes;
|
||||
gDebugger.once(gDebugger.EVENTS.AFTER_FRAMES_CLEARED, () => {
|
||||
is(gFrames.itemCount, 0,
|
||||
"Should have no frames after resume.");
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
closeDebuggerAndFinish(gPanel);
|
||||
}, true);
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 2,
|
||||
"Should have two frames.");
|
||||
|
||||
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
|
||||
"All children should be frames.");
|
||||
|
||||
|
||||
gDebugger.addEventListener("Debugger:AfterFramesCleared", function listener() {
|
||||
gDebugger.removeEventListener("Debugger:AfterFramesCleared", listener, true);
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 0,
|
||||
"Should have no frames after resume");
|
||||
|
||||
is(childNodes.length, 0,
|
||||
"Should only have no children.");
|
||||
|
||||
closeDebuggerAndFinish();
|
||||
}, true);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.resume();
|
||||
}}, 0);
|
||||
});
|
||||
|
||||
gDebuggee.evalCall();
|
||||
gDebugger.gThreadClient.resume();
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gFrames = null;
|
||||
});
|
||||
|
@ -1,114 +1,154 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that switching between stack frames properly sets the current debugger
|
||||
* location in the source editor.
|
||||
*/
|
||||
|
||||
// Test that switching between stack frames properly sets the current debugger
|
||||
// location in the source editor.
|
||||
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebuggee = null;
|
||||
var gDebugger = null;
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources, gFrames;
|
||||
|
||||
function test() {
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gEditor = gDebugger.DebuggerView.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gFrames = gDebugger.DebuggerView.StackFrames;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
|
||||
let url = aEvent.detail.url;
|
||||
if (url.indexOf("-02.js") != -1) {
|
||||
scriptShown = true;
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
runTest();
|
||||
}
|
||||
});
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
framesAdded = true;
|
||||
runTest();
|
||||
});
|
||||
waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6)
|
||||
.then(initialChecks)
|
||||
.then(testNewestTwoFrames)
|
||||
.then(testOldestTwoFrames)
|
||||
.then(testAfterResume)
|
||||
.then(() => closeDebuggerAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
|
||||
function runTest()
|
||||
{
|
||||
if (scriptShown && framesAdded) {
|
||||
Services.tm.currentThread.dispatch({ run: testRecurse }, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testRecurse()
|
||||
{
|
||||
let frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
let childNodes = frames.childNodes;
|
||||
function initialChecks() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gFrames.itemCount, 4,
|
||||
"Should have four frames.");
|
||||
}
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 4,
|
||||
"Correct number of frames.");
|
||||
function testNewestTwoFrames() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
|
||||
"All children should be frames.");
|
||||
is(gFrames.selectedIndex, 3,
|
||||
"Newest frame should be selected by default.");
|
||||
is(gSources.selectedIndex, 1,
|
||||
"The second source is selected in the widget.");
|
||||
ok(isCaretPos(gPanel, 6),
|
||||
"Editor caret location is correct.");
|
||||
|
||||
ok(frames.querySelector("#stackframe-0").parentNode.hasAttribute("checked"),
|
||||
"First frame should be selected by default.");
|
||||
// The editor's debug location takes a tick to update.
|
||||
executeSoon(() => {
|
||||
is(gEditor.getDebugLocation(), 5,
|
||||
"Editor debug location is correct.");
|
||||
|
||||
ok(!frames.querySelector("#stackframe-2").parentNode.hasAttribute("checked"),
|
||||
"Third frame should not be selected.");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gFrames.getItemAtIndex(2).target,
|
||||
gDebugger);
|
||||
|
||||
is(gDebugger.editor.getDebugLocation(), 5,
|
||||
"editor debugger location is correct.");
|
||||
is(gFrames.selectedIndex, 2,
|
||||
"Third frame should be selected after click.");
|
||||
is(gSources.selectedIndex, 1,
|
||||
"The second source is still selected in the widget.");
|
||||
ok(isCaretPos(gPanel, 6),
|
||||
"Editor caret location is correct.");
|
||||
|
||||
// The editor's debug location takes a tick to update.
|
||||
executeSoon(() => {
|
||||
is(gEditor.getDebugLocation(), 5,
|
||||
"Editor debug location is correct.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
frames.querySelector("#stackframe-2"),
|
||||
gDebugger);
|
||||
|
||||
ok(!frames.querySelector("#stackframe-0").parentNode.hasAttribute("checked"),
|
||||
"First frame should not be selected after click.");
|
||||
|
||||
ok(frames.querySelector("#stackframe-2").parentNode.hasAttribute("checked"),
|
||||
"Third frame should be selected after click.");
|
||||
|
||||
is(gDebugger.editor.getDebugLocation(), 4,
|
||||
"editor debugger location is correct after click.");
|
||||
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
frames.querySelector("#stackframe-0 .dbg-stackframe-title"),
|
||||
gDebugger);
|
||||
|
||||
ok(frames.querySelector("#stackframe-0").parentNode.hasAttribute("checked"),
|
||||
"First frame should be selected after click inside the first frame.");
|
||||
|
||||
ok(!frames.querySelector("#stackframe-2").parentNode.hasAttribute("checked"),
|
||||
"Third frame should not be selected after click inside the first frame.");
|
||||
|
||||
is(gDebugger.editor.getDebugLocation(), 5,
|
||||
"editor debugger location is correct (frame 0 again).");
|
||||
|
||||
gDebugger.DebuggerController.activeThread.resume(function() {
|
||||
is(gDebugger.editor.getDebugLocation(), -1,
|
||||
"editor debugger location is correct after resume.");
|
||||
|
||||
closeDebuggerAndFinish();
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testOldestTwoFrames() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
waitForSourceAndCaret(gPanel, "-01.js", 5).then(() => {
|
||||
is(gFrames.selectedIndex, 1,
|
||||
"Second frame should be selected after click.");
|
||||
is(gSources.selectedIndex, 0,
|
||||
"The first source is now selected in the widget.");
|
||||
ok(isCaretPos(gPanel, 5),
|
||||
"Editor caret location is correct.");
|
||||
|
||||
// The editor's debug location takes a tick to update.
|
||||
executeSoon(() => {
|
||||
is(gEditor.getDebugLocation(), 4,
|
||||
"Editor debug location is correct.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gFrames.getItemAtIndex(0).target,
|
||||
gDebugger);
|
||||
|
||||
is(gFrames.selectedIndex, 0,
|
||||
"Oldest frame should be selected after click.");
|
||||
is(gSources.selectedIndex, 0,
|
||||
"The first source is still selected in the widget.");
|
||||
ok(isCaretPos(gPanel, 5),
|
||||
"Editor caret location is correct.");
|
||||
|
||||
// The editor's debug location takes a tick to update.
|
||||
executeSoon(() => {
|
||||
is(gEditor.getDebugLocation(), 4,
|
||||
"Editor debug location is correct.");
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gFrames.getItemAtIndex(1).target,
|
||||
gDebugger);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testAfterResume() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
gDebugger.once(gDebugger.EVENTS.AFTER_FRAMES_CLEARED, () => {
|
||||
is(gFrames.itemCount, 0,
|
||||
"Should have no frames after resume.");
|
||||
ok(isCaretPos(gPanel, 5),
|
||||
"Editor caret location is correct after resume.");
|
||||
is(gEditor.getDebugLocation(), -1,
|
||||
"Editor debug location is correct after resume.");
|
||||
|
||||
deferred.resolve();
|
||||
}, true);
|
||||
|
||||
gDebugger.gThreadClient.resume();
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gFrames = null;
|
||||
});
|
||||
|
||||
|
65
browser/devtools/debugger/test/browser_dbg_stack-06.js
Normal file
65
browser/devtools/debugger/test/browser_dbg_stack-06.js
Normal file
@ -0,0 +1,65 @@
|
||||
/* 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 source in the editor
|
||||
* pane and highlights the proper line.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources, gFrames;
|
||||
|
||||
function test() {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gEditor = gDebugger.DebuggerView.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gFrames = gDebugger.DebuggerView.StackFrames;
|
||||
|
||||
waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6).then(performTest);
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
}
|
||||
|
||||
function performTest() {
|
||||
is(gFrames.selectedIndex, 3,
|
||||
"Newest frame should be selected by default.");
|
||||
is(gSources.selectedIndex, 1,
|
||||
"The second source is selected in the widget.");
|
||||
is(gEditor.getText().search(/firstCall/), -1,
|
||||
"The first source is not displayed.");
|
||||
is(gEditor.getText().search(/debugger/), 172,
|
||||
"The second source is displayed.")
|
||||
|
||||
waitForSourceAndCaret(gPanel, "-01.js", 6).then(() => {
|
||||
is(gFrames.selectedIndex, 0,
|
||||
"Oldest frame should be selected after click.");
|
||||
is(gSources.selectedIndex, 0,
|
||||
"The first source is now selected in the widget.");
|
||||
is(gEditor.getText().search(/firstCall/), 118,
|
||||
"The first source is displayed.");
|
||||
is(gEditor.getText().search(/debugger/), -1,
|
||||
"The second source is not displayed.");
|
||||
|
||||
resumeDebuggerThenCloseAndFinish(gPanel);
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gDebugger.document.querySelector("#stackframe-3"),
|
||||
gDebugger);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
gFrames = null;
|
||||
});
|
Loading…
Reference in New Issue
Block a user