Bug 1317485 - Allow null frames object to prevent throwing when there aren't sources on the page;r=jlongster
MozReview-Commit-ID: 13K7lThy5fg
--- a/devtools/client/debugger/new/panel.js
+++ b/devtools/client/debugger/new/panel.js
@@ -45,17 +45,17 @@ DebuggerPanel.prototype = {
_selectors: function() {
return this.panelWin.Debugger.selectors;
},
getFrames: function() {
let frames = this._selectors().getFrames(this._getState());
// frames is an empty array when the debugger is not paused
- if (!frames.toJS) {
+ if (!frames || !frames.toJS) {
return {
frames: [],
selected: -1
}
}
frames = frames.toJS();
const selectedFrame = this._selectors().getSelectedFrame(this._getState());
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-console.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-console.js
@@ -22,13 +22,16 @@ function getSplitConsole(dbg) {
let jsterm = toolbox.getPanel("webconsole").hud.jsterm;
resolve(jsterm);
});
});
}
add_task(function* () {
Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true);
- const dbg = yield initDebugger("doc-script-switching.html");
+ const dbg = yield initDebugger("data:text/html;charset=utf-8,");
- yield getSplitConsole(dbg);
+ const jsterm = yield getSplitConsole(dbg);
ok(dbg.toolbox.splitConsole, "Split console is shown.");
+
+ info("Evaluating a script in the console");
+ yield jsterm.execute("1+1");
});
--- a/devtools/client/debugger/new/test/mochitest/head.js
+++ b/devtools/client/debugger/new/test/mochitest/head.js
@@ -296,17 +296,18 @@ function createDebuggerContext(toolbox)
* @memberof mochitest
* @param {String} url
* @param {Array} sources
* @return {Promise} dbg
* @static
*/
function initDebugger(url, ...sources) {
return Task.spawn(function* () {
- const toolbox = yield openNewTabAndToolbox(EXAMPLE_URL + url, "jsdebugger");
+ url = url.startsWith("data:") ? url : EXAMPLE_URL + url;
+ const toolbox = yield openNewTabAndToolbox(url, "jsdebugger");
return createDebuggerContext(toolbox);
});
}
window.resumeTest = undefined;
/**
* Pause the test and let you interact with the debugger.
* The test can be resumed by invoking `resumeTest` in the console.