2012-07-12 04:03:43 -07:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure that the debugger is updated with the correct scripts when moving
|
|
|
|
* back and forward in the tab.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
|
|
|
var gPane = null;
|
|
|
|
var gTab = null;
|
|
|
|
var gDebuggee = null;
|
|
|
|
var gDebugger = null;
|
2013-02-20 15:33:36 -08:00
|
|
|
var gSources = null;
|
2012-07-12 04:03:43 -07:00
|
|
|
|
|
|
|
function test()
|
|
|
|
{
|
|
|
|
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
|
|
|
gTab = aTab;
|
|
|
|
gDebuggee = aDebuggee;
|
|
|
|
gPane = aPane;
|
2012-11-30 00:07:59 -08:00
|
|
|
gDebugger = gPane.panelWin;
|
2012-07-12 04:03:43 -07:00
|
|
|
|
|
|
|
testInitialLoad();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testInitialLoad() {
|
|
|
|
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
|
|
|
executeSoon(function() {
|
|
|
|
validateFirstPage();
|
|
|
|
testLocationChange();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gDebuggee.firstCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLocationChange()
|
|
|
|
{
|
|
|
|
gDebugger.DebuggerController.activeThread.resume(function() {
|
2013-04-04 01:23:42 -07:00
|
|
|
gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
|
2012-08-24 00:41:02 -07:00
|
|
|
ok(true, "tabNavigated event was fired.");
|
|
|
|
info("Still attached to the tab.");
|
|
|
|
|
2013-02-28 04:02:00 -08:00
|
|
|
gDebugger.addEventListener("Debugger:AfterSourcesAdded", function _onEvent(aEvent) {
|
2012-08-24 00:41:02 -07:00
|
|
|
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
|
|
|
|
2012-07-12 04:03:43 -07:00
|
|
|
executeSoon(function() {
|
|
|
|
validateSecondPage();
|
|
|
|
testBack();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
content.location = STACK_URL;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testBack()
|
|
|
|
{
|
2013-04-04 01:23:42 -07:00
|
|
|
gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
|
2012-08-24 00:41:02 -07:00
|
|
|
ok(true, "tabNavigated event was fired after going back.");
|
|
|
|
info("Still attached to the tab.");
|
|
|
|
|
2013-02-28 04:02:00 -08:00
|
|
|
gDebugger.addEventListener("Debugger:AfterSourcesAdded", function _onEvent(aEvent) {
|
2012-08-24 00:41:02 -07:00
|
|
|
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
|
|
|
|
2012-07-12 04:03:43 -07:00
|
|
|
executeSoon(function() {
|
|
|
|
validateFirstPage();
|
|
|
|
testForward();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
info("Going back.");
|
|
|
|
content.history.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testForward()
|
|
|
|
{
|
2013-04-04 01:23:42 -07:00
|
|
|
gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
|
2012-08-24 00:41:02 -07:00
|
|
|
ok(true, "tabNavigated event was fired after going forward.");
|
|
|
|
info("Still attached to the tab.");
|
|
|
|
|
2013-02-28 04:02:00 -08:00
|
|
|
gDebugger.addEventListener("Debugger:AfterSourcesAdded", function _onEvent(aEvent) {
|
2012-08-24 00:41:02 -07:00
|
|
|
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
|
|
|
|
2012-07-12 04:03:43 -07:00
|
|
|
executeSoon(function() {
|
|
|
|
validateSecondPage();
|
|
|
|
closeDebuggerAndFinish();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
info("Going forward.");
|
|
|
|
content.history.forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateFirstPage() {
|
2013-02-20 15:33:36 -08:00
|
|
|
gSources = gDebugger.DebuggerView.Sources;
|
2012-07-12 04:03:43 -07:00
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
is(gSources.itemCount, 2,
|
|
|
|
"Found the expected number of scripts.");
|
2012-07-12 04:03:43 -07:00
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
ok(gDebugger.DebuggerView.Sources.containsLabel("test-script-switching-01.js"),
|
2012-07-12 04:03:43 -07:00
|
|
|
"Found the first script label.");
|
2013-02-20 15:33:36 -08:00
|
|
|
ok(gDebugger.DebuggerView.Sources.containsLabel("test-script-switching-02.js"),
|
2012-07-12 04:03:43 -07:00
|
|
|
"Found the second script label.");
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateSecondPage() {
|
2013-02-20 15:33:36 -08:00
|
|
|
gSources = gDebugger.DebuggerView.Sources;
|
2012-07-12 04:03:43 -07:00
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
is(gSources.itemCount, 1,
|
|
|
|
"Found the expected number of scripts.");
|
2012-07-12 04:03:43 -07:00
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
ok(gDebugger.DebuggerView.Sources.containsLabel("browser_dbg_stack.html"),
|
2012-07-12 04:03:43 -07:00
|
|
|
"Found the single script label.");
|
|
|
|
}
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
removeTab(gTab);
|
|
|
|
gPane = null;
|
|
|
|
gTab = null;
|
|
|
|
gDebuggee = null;
|
|
|
|
gDebugger = null;
|
2013-02-20 15:33:36 -08:00
|
|
|
gSources = null;
|
2012-07-12 04:03:43 -07:00
|
|
|
});
|