Bug 781186 - Navigating between pages initially shows 'No Scripts' in the menulist, r=rcampbell

This commit is contained in:
Victor Porof 2012-08-09 00:36:23 +03:00
parent 90e44e7a50
commit dc04135167
3 changed files with 93 additions and 1 deletions

View File

@ -934,7 +934,7 @@ SourceScripts.prototype = {
// Select the preferred script if one exists, the first entry otherwise.
let preferredScriptUrl = DebuggerView.Scripts.preferredScriptUrl;
if (preferredScriptUrl) {
if (preferredScriptUrl && DebuggerView.Scripts.contains(preferredScriptUrl)) {
DebuggerView.Scripts.selectScript(preferredScriptUrl);
} else {
DebuggerView.Scripts.selectIndex(0);

View File

@ -44,6 +44,7 @@ MOCHITEST_BROWSER_TESTS = \
browser_dbg_stack-04.js \
browser_dbg_stack-05.js \
browser_dbg_location-changes.js \
browser_dbg_location-changes-new.js \
browser_dbg_location-changes-blank.js \
browser_dbg_script-switching.js \
browser_dbg_scripts-sorting.js \

View File

@ -0,0 +1,91 @@
/* 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 changing the tab location URL to a page with other scripts works.
*/
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
function test()
{
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.contentWindow;
testSimpleCall();
});
}
function testSimpleCall() {
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
Services.tm.currentThread.dispatch({
run: function() {
var frames = gDebugger.DebuggerView.StackFrames._frames,
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.");
isnot(gDebugger.DebuggerView.Scripts.selected, null,
"There should be a selected script.");
isnot(gDebugger.editor.getText().length, 0,
"The source editor should have some text displayed.");
testLocationChange();
}
}, 0);
});
gDebuggee.simpleCall();
}
function testLocationChange()
{
gDebugger.DebuggerController.activeThread.resume(function() {
gDebugger.DebuggerController.client.addOneTimeListener("tabNavigated", function(aEvent, aPacket) {
ok(true, "tabNavigated event was fired.");
gDebugger.DebuggerController.client.addOneTimeListener("tabAttached", function(aEvent, aPacket) {
ok(true, "Successfully reattached to the tab again.");
// Wait for the initial resume...
gDebugger.gClient.addOneTimeListener("resumed", function() {
isnot(gDebugger.DebuggerView.Scripts.selected, null,
"There should be a selected script.");
isnot(gDebugger.editor.getText().length, 0,
"The source editor should have some text displayed.");
let menulist = gDebugger.DebuggerView.Scripts._scripts;
let noScripts = gDebugger.L10N.getStr("noScriptsText");
isnot(menulist.getAttribute("label"), noScripts,
"The menulist should not display a notice that there are no scripts availalble.");
isnot(menulist.getAttribute("tooltiptext"), "",
"The menulist should have a tooltip text attributed.");
closeDebuggerAndFinish();
});
});
});
content.location = EXAMPLE_URL + "browser_dbg_iframes.html";
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});