Bug 767384 - The script from the dropdown is kept when loading a page with no scripts after loading one with scripts and opening the Debugger; r=past

This commit is contained in:
Victor Porof 2012-07-15 10:06:02 +03:00
Родитель 7e51c4b66e
Коммит c13d9e632d
4 изменённых файлов: 94 добавлений и 1 удалений

Просмотреть файл

@ -933,6 +933,7 @@ SourceScripts.prototype = {
_onScriptsCleared: function SS__onScriptsCleared() {
DebuggerView.Scripts.empty();
DebuggerView.Breakpoints.emptyText();
DebuggerView.editor.setText("");
},
/**

Просмотреть файл

@ -148,6 +148,8 @@ ScriptsView.prototype = {
* Removes all elements from the scripts container, leaving it empty.
*/
empty: function DVS_empty() {
this._scripts.selectedIndex = -1;
while (this._scripts.firstChild) {
this._scripts.removeChild(this._scripts.firstChild);
}
@ -418,7 +420,12 @@ ScriptsView.prototype = {
* The click listener for the scripts container.
*/
_onScriptsChange: function DVS__onScriptsChange() {
let script = this._scripts.selectedItem.getUserData("sourceScript");
let selectedItem = this._scripts.selectedItem;
if (!selectedItem) {
return;
}
let script = selectedItem.getUserData("sourceScript");
this._preferredScript = script;
DebuggerController.SourceScripts.showScript(script);
},

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,84 @@
/* 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 no 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() {
is(gDebugger.DebuggerView.Scripts.selected, null,
"There should be no selected script.");
is(gDebugger.editor.getText().length, 0,
"The source editor not have any text displayed.");
closeDebuggerAndFinish();
});
});
});
content.location = "about:blank";
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});