mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 773732 - After reloading a page, the selected script and line should remain the same, r=rcampbell
This commit is contained in:
parent
b70f4a81e2
commit
0927273ead
@ -908,6 +908,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) {
|
||||
@ -926,6 +931,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.selectScript(preferredScriptUrl);
|
||||
} else {
|
||||
DebuggerView.Scripts.selectIndex(0);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -239,6 +239,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.
|
||||
*
|
||||
@ -277,6 +287,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
|
||||
@ -345,7 +362,7 @@ ScriptsView.prototype = {
|
||||
}
|
||||
}
|
||||
// The script is alphabetically the last one.
|
||||
this._createScriptElement(aLabel, aScript, -1, true);
|
||||
this._createScriptElement(aLabel, aScript, -1);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -365,7 +382,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);
|
||||
}
|
||||
},
|
||||
|
||||
@ -380,12 +397,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)) {
|
||||
@ -398,10 +411,6 @@ ScriptsView.prototype = {
|
||||
|
||||
scriptItem.setAttribute("tooltiptext", aScript.url);
|
||||
scriptItem.setUserData("sourceScript", aScript, null);
|
||||
|
||||
if (this._scripts.itemCount == 1 && aSelectIfEmptyFlag) {
|
||||
this._scripts.selectedItem = scriptItem;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -437,6 +446,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 \
|
||||
|
126
browser/devtools/debugger/test/browser_dbg_reload-same-script.js
Normal file
126
browser/devtools/debugger/test/browser_dbg_reload-same-script.js
Normal file
@ -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;
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user