diff --git a/browser/devtools/debugger/test/browser.ini b/browser/devtools/debugger/test/browser.ini index 467e6f47d64f..7d8ba0c5a960 100644 --- a/browser/devtools/debugger/test/browser.ini +++ b/browser/devtools/debugger/test/browser.ini @@ -202,6 +202,8 @@ skip-if = e10s && debug skip-if = e10s && debug [browser_dbg_conditional-breakpoints-05.js] skip-if = e10s && debug +[browser_dbg_console-eval.js] +skip-if = e10s && debug [browser_dbg_server-conditional-bp-01.js] skip-if = e10s && debug [browser_dbg_server-conditional-bp-02.js] diff --git a/browser/devtools/debugger/test/browser_dbg_console-eval.js b/browser/devtools/debugger/test/browser_dbg_console-eval.js new file mode 100644 index 000000000000..3170f5ac6d3c --- /dev/null +++ b/browser/devtools/debugger/test/browser_dbg_console-eval.js @@ -0,0 +1,42 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Breaking in the middle of a script evaluated by the console should + * work + */ + +function test() { + Task.spawn(runTests); +} + +function* runTests() { + let TAB_URL = EXAMPLE_URL + "doc_empty-tab-01.html"; + let [,, panel] = yield initDebugger(TAB_URL); + let dbgWin = panel.panelWin; + let sources = dbgWin.DebuggerView.Sources; + let frames = dbgWin.DebuggerView.StackFrames; + let editor = dbgWin.DebuggerView.editor; + let toolbox = gDevTools.getToolbox(panel.target); + + let paused = promise.all([ + waitForEditorEvents(panel, "cursorActivity"), + waitForDebuggerEvents(panel, dbgWin.EVENTS.SOURCE_SHOWN) + ]); + + toolbox.once("webconsole-ready", () => { + ok(toolbox.splitConsole, "Split console is shown."); + let jsterm = toolbox.getPanel("webconsole").hud.jsterm; + jsterm.execute('debugger'); + }); + EventUtils.synthesizeKey("VK_ESCAPE", {}, dbgWin); + + yield paused; + is(sources.selectedItem.attachment.label, 'SCRIPT0', + 'Anonymous source is selected in sources'); + dump('text ::' + editor.getText() + '::\n'); + ok(editor.getText() === 'debugger', 'Editor has correct text'); + + yield toolbox.closeSplitConsole(); + yield resumeDebuggerThenCloseAndFinish(panel); +} diff --git a/toolkit/devtools/server/actors/script.js b/toolkit/devtools/server/actors/script.js index 865b150a4bee..386152309766 100644 --- a/toolkit/devtools/server/actors/script.js +++ b/toolkit/devtools/server/actors/script.js @@ -5407,6 +5407,10 @@ function getSourceURL(source) { return source.displayURL; } + else if(source.url === 'debugger eval code') { + // Treat code evaluated by the console as unnamed eval scripts + return null; + } return source.url; } exports.getSourceURL = getSourceURL; diff --git a/toolkit/devtools/server/actors/utils/TabSources.js b/toolkit/devtools/server/actors/utils/TabSources.js index f57feda64811..61b2778fad6d 100644 --- a/toolkit/devtools/server/actors/utils/TabSources.js +++ b/toolkit/devtools/server/actors/utils/TabSources.js @@ -296,11 +296,9 @@ TabSources.prototype = { spec.contentType = "text/javascript"; } } catch(ex) { - // Not a valid URI. - - // bug 1124536: fix getSourceText on scripts associated "javascript:SOURCE" urls - // (e.g. 'evaluate(sandbox, sourcecode, "javascript:"+sourcecode)' ) - if (url.indexOf("javascript:") === 0) { + // There are a few special URLs that we know are JavaScript: + // inline `javascript:` and code coming from the console + if (url.indexOf("javascript:") === 0 || url === 'debugger eval code') { spec.contentType = "text/javascript"; } }