Backout 3b46b03dff5c, effectively relanding bug 781186 and 773732 because it seems like a clean backout isn't going to be possible

This commit is contained in:
Ed Morley 2012-08-15 15:26:46 +01:00
Родитель 2fa3cc6685
Коммит 98d259b68b
5 изменённых файлов: 253 добавлений и 11 удалений

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

@ -909,6 +909,11 @@ SourceScripts.prototype = {
this._addScript({ url: aPacket.url, startLine: aPacket.startLine }, true);
// Select the script if it's the preferred one.
if (aPacket.url === DebuggerView.Scripts.preferredScriptUrl) {
DebuggerView.Scripts.selectScript(aPacket.url);
}
// If there are any stored breakpoints for this script, display them again,
// both in the editor and the pane.
for each (let breakpoint in DebuggerController.Breakpoints.store) {
@ -927,6 +932,14 @@ SourceScripts.prototype = {
}
DebuggerView.Scripts.commitScripts();
DebuggerController.Breakpoints.updatePaneBreakpoints();
// Select the preferred script if one exists, the first entry otherwise.
let preferredScriptUrl = DebuggerView.Scripts.preferredScriptUrl;
if (preferredScriptUrl && DebuggerView.Scripts.contains(preferredScriptUrl)) {
DebuggerView.Scripts.selectScript(preferredScriptUrl);
} else {
DebuggerView.Scripts.selectIndex(0);
}
},
/**

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

@ -245,6 +245,16 @@ ScriptsView.prototype = {
return false;
},
/**
* Selects the script with the specified index from the list.
*
* @param number aIndex
* The script index.
*/
selectIndex: function DVS_selectIndex(aIndex) {
this._scripts.selectedIndex = aIndex;
},
/**
* Selects the script with the specified URL from the list.
*
@ -283,6 +293,13 @@ ScriptsView.prototype = {
this._scripts.selectedItem.value : null;
},
/**
* Gets the most recently selected script url.
* @return string | null
*/
get preferredScriptUrl()
this._preferredScriptUrl ? this._preferredScriptUrl : null,
/**
* Returns the list of labels in the scripts container.
* @return array
@ -351,7 +368,7 @@ ScriptsView.prototype = {
}
}
// The script is alphabetically the last one.
this._createScriptElement(aLabel, aScript, -1, true);
this._createScriptElement(aLabel, aScript, -1);
},
/**
@ -371,7 +388,7 @@ ScriptsView.prototype = {
for (let i = 0, l = newScripts.length; i < l; i++) {
let item = newScripts[i];
this._createScriptElement(item.label, item.script, -1, true);
this._createScriptElement(item.label, item.script, -1);
}
},
@ -386,12 +403,8 @@ ScriptsView.prototype = {
* @param number aIndex
* The index where to insert to new script in the container.
* Pass -1 to append the script at the end.
* @param boolean aSelectIfEmptyFlag
* True to set the newly created script as the currently selected item
* if there are no other existing scripts in the container.
*/
_createScriptElement: function DVS__createScriptElement(
aLabel, aScript, aIndex, aSelectIfEmptyFlag)
_createScriptElement: function DVS__createScriptElement(aLabel, aScript, aIndex)
{
// Make sure we don't duplicate anything.
if (aLabel == "null" || this.containsLabel(aLabel) || this.contains(aScript.url)) {
@ -404,10 +417,6 @@ ScriptsView.prototype = {
scriptItem.setAttribute("tooltiptext", aScript.url);
scriptItem.setUserData("sourceScript", aScript, null);
if (this._scripts.itemCount == 1 && aSelectIfEmptyFlag) {
this._scripts.selectedItem = scriptItem;
}
},
/**
@ -443,6 +452,7 @@ ScriptsView.prototype = {
}
this._preferredScript = selectedItem;
this._preferredScriptUrl = selectedItem.value;
this._scripts.setAttribute("tooltiptext", selectedItem.value);
DebuggerController.SourceScripts.showScript(selectedItem.getUserData("sourceScript"));
},

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

@ -35,6 +35,7 @@ MOCHITEST_BROWSER_TESTS = \
browser_dbg_propertyview-09.js \
browser_dbg_propertyview-10.js \
browser_dbg_propertyview-edit.js \
browser_dbg_reload-same-script.js \
browser_dbg_panesize.js \
browser_dbg_panesize-inner.js \
browser_dbg_stack-01.js \
@ -43,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 \

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

@ -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;
});

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

@ -0,0 +1,126 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if the same script is shown after a page is reloaded.
*/
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
let gPane = null;
let gTab = null;
let gDebuggee = null;
let gDebugger = null;
let gView = null;
function test()
{
let step = 0;
let scriptShown = false;
let scriptShownUrl = null;
let resumed = false;
let testStarted = false;
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.contentWindow;
gView = gDebugger.DebuggerView;
resumed = true;
executeSoon(startTest);
});
function onScriptShown(aEvent)
{
scriptShown = aEvent.detail.url.indexOf("-01.js") != -1;
scriptShownUrl = aEvent.detail.url;
executeSoon(startTest);
}
function onUlteriorScriptShown(aEvent)
{
scriptShownUrl = aEvent.detail.url;
executeSoon(testScriptShown);
}
window.addEventListener("Debugger:ScriptShown", onScriptShown);
function startTest()
{
if (scriptShown && resumed && !testStarted) {
window.removeEventListener("Debugger:ScriptShown", onScriptShown);
window.addEventListener("Debugger:ScriptShown", onUlteriorScriptShown);
testStarted = true;
Services.tm.currentThread.dispatch({ run: performTest }, 0);
}
}
function finishTest()
{
if (scriptShown && resumed && testStarted) {
window.removeEventListener("Debugger:ScriptShown", onUlteriorScriptShown);
closeDebuggerAndFinish();
}
}
function performTest()
{
testCurrentScript("-01.js", step);
step = 1;
reloadPage();
}
function testScriptShown()
{
if (step === 1) {
testCurrentScript("-01.js", step);
step = 2;
reloadPage();
}
else if (step === 2) {
testCurrentScript("-01.js", step);
step = 3;
gView.Scripts.selectScript(gView.Scripts.scriptLocations[1]);
}
else if (step === 3) {
testCurrentScript("-02.js", step);
step = 4;
reloadPage();
}
else if (step === 4) {
testCurrentScript("-02.js", step);
finishTest();
}
}
function testCurrentScript(part, step)
{
info("Currently preferred script: " + gView.Scripts.preferredScriptUrl);
info("Currently selected script: " + gView.Scripts.selected);
isnot(gView.Scripts.preferredScriptUrl.indexOf(part), -1,
"The preferred script url wasn't set correctly. (" + step + ")");
isnot(gView.Scripts.selected.indexOf(part), -1,
"The selected script isn't the correct one. (" + step + ")");
is(gView.Scripts.selected, scriptShownUrl,
"The shown script is not the the correct one. (" + step + ")");
}
function reloadPage()
{
executeSoon(function() {
gDebuggee.location.reload();
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
gView = null;
});
}