Bug 884484 - Don't show Loading... forever if loading a source fails; r=fitzgen

This commit is contained in:
Hubert B Manilla 2013-09-05 09:10:12 -07:00
parent 28a868781a
commit 10aec2ea5b
4 changed files with 71 additions and 2 deletions

View File

@ -28,6 +28,8 @@ const SEARCH_TOKEN_FLAG = "#";
const SEARCH_LINE_FLAG = ":";
const SEARCH_VARIABLE_FLAG = "*";
Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm");
/**
* Object defining the debugger view components.
*/
@ -279,8 +281,10 @@ let DebuggerView = {
window.dispatchEvent(document, "Debugger:SourceShown", aSource);
},
([, aError]) => {
// Rejected. TODO: Bug 884484.
let msg = "Error loading: " + aSource.url + "\n" + aError;
// Rejected.
let msg = L10N.getStr("errorLoadingText") + DevToolsUtils.safeErrorString(aError);
this.editor.setText(msg);
window.dispatchEvent(document, "Debugger:SourceErrorShown", aError);
dumpn(msg);
Cu.reportError(msg);
});

View File

@ -67,6 +67,7 @@ MOCHITEST_BROWSER_TESTS = \
browser_dbg_sources-cache.js \
browser_dbg_scripts-switching.js \
browser_dbg_scripts-switching-02.js \
browser_dbg_scripts-switching-03.js \
browser_dbg_scripts-sorting.js \
browser_dbg_scripts-searching-01.js \
browser_dbg_scripts-searching-02.js \

View File

@ -0,0 +1,60 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Make sure that the Debugger-View error loading source text is correct
*/
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
var gView = null;
var gL10N = null;
function test()
{
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane){
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.panelWin;
gView = gDebugger.DebuggerView;
gL10N = gDebugger.L10N;
gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
});
}
function onScriptShown(aEvent)
{
gView.editorSource = { url: "http://example.com/fake.js", actor: "fake.actor" };
gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
gDebugger.addEventListener("Debugger:SourceErrorShown", onScriptErrorShown);
}
function onScriptErrorShown(aEvent)
{
gDebugger.removeEventListener("Debugger:SourceErrorShown", onScriptErrorShown);
testDebuggerLoadingError();
}
function testDebuggerLoadingError()
{
ok(gDebugger.editor.getText().search(new RegExp(gL10N.getStr("errorLoadingText")) != -1),
"The valid error loading message is displayed.");
closeDebuggerAndFinish();
}
registerCleanupFunction(function()
{
removeTab(gTab);
gPane = null;
gTab = null;
gDebugger = null;
gView = null;
gDebuggee = null;
gL10N = null;
});

View File

@ -133,6 +133,10 @@ breakpointMenuItem.deleteAll=Remove all breakpoints
# yet.
loadingText=Loading\u2026
# LOCALIZATION NOTE (errorLoadingText): The text that is displayed in the debugger
# viewer when there is an error loading a file
errorLoadingText=Error loading source:\n
# LOCALIZATION NOTE (emptyStackText): The text that is displayed in the watch
# expressions list to add a new item.
addWatchExpressionText=Add watch expression