From 717071e5096d91e2ff5d30ed162eea0a2dfb1142 Mon Sep 17 00:00:00 2001 From: James Long Date: Wed, 21 Oct 2015 10:55:00 +0200 Subject: [PATCH] Bug 1201008 - only add a breakpoint in the debugger if a source is actually loaded. r=bgrins --HG-- extra : rebase_source : 8af6cdc227f09dc528ce27e26b4f0054d7f6f0d2 --- devtools/client/debugger/debugger-view.js | 5 +++- .../debugger/test/mochitest/browser.ini | 2 ++ .../browser_dbg_no-dangling-breakpoints.js | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg_no-dangling-breakpoints.js diff --git a/devtools/client/debugger/debugger-view.js b/devtools/client/debugger/debugger-view.js index 5fc9c0c18a19..bd7026c0c89d 100644 --- a/devtools/client/debugger/debugger-view.js +++ b/devtools/client/debugger/debugger-view.js @@ -311,7 +311,10 @@ var DebuggerView = { if (button == 2) { this.clickedLine = line; } - else { + // Bug 1201008: Only add the breakpoint to the editor if we're currently + // looking at a source. Even if no source is loaded, you can + // interact with line 1 of the editor. + else if (DebuggerView.Sources.selectedValue) { if (this.editor.hasBreakpoint(line)) { this.editor.removeBreakpoint(line); } else { diff --git a/devtools/client/debugger/test/mochitest/browser.ini b/devtools/client/debugger/test/mochitest/browser.ini index 83ac4bd24210..be8b6b90e9bb 100644 --- a/devtools/client/debugger/test/mochitest/browser.ini +++ b/devtools/client/debugger/test/mochitest/browser.ini @@ -289,6 +289,8 @@ skip-if = e10s # TODO skip-if = e10s # TODO [browser_dbg_navigation.js] skip-if = e10s && debug +[browser_dbg_no-dangling-breakpoints.js] +skip-if = e10s && debug [browser_dbg_no-page-sources.js] skip-if = e10s && debug [browser_dbg_on-pause-highlight.js] diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_no-dangling-breakpoints.js b/devtools/client/debugger/test/mochitest/browser_dbg_no-dangling-breakpoints.js new file mode 100644 index 000000000000..2e093cf0ae15 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_no-dangling-breakpoints.js @@ -0,0 +1,23 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Bug 1201008 - Make sure you can't set a breakpoint in a blank + * editor + */ + +function test() { + initDebugger('data:text/html,hi').then(([aTab,, aPanel]) => { + const gPanel = aPanel; + const gDebugger = gPanel.panelWin; + + Task.spawn(function*() { + const editor = gDebugger.DebuggerView.editor; + editor.emit("gutterClick", 0); + is(editor.getBreakpoints().length, 0, + "A breakpoint should not exist"); + + closeDebuggerAndFinish(gPanel); + }); + }); +}