Bug 1543999 - Shift-clicking the gutter should create disabled breakpoint r=jlast
authorDavid Walsh <dwalsh@mozilla.com>
Fri, 12 Apr 2019 18:35:31 +0000
changeset 469685 a67dae409401
parent 469684 7a36097057bd
child 469686 d245ef38503c
push id35879
push usernerli@mozilla.com
push dateTue, 16 Apr 2019 22:01:48 +0000
treeherdermozilla-central@12a60898fdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1543999
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1543999 - Shift-clicking the gutter should create disabled breakpoint r=jlast Differential Revision: https://phabricator.services.mozilla.com/D27286
devtools/client/debugger/src/actions/breakpoints/index.js
devtools/client/debugger/src/components/Editor/index.js
devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js
devtools/client/debugger/test/mochitest/helpers.js
--- a/devtools/client/debugger/src/actions/breakpoints/index.js
+++ b/devtools/client/debugger/src/actions/breakpoints/index.js
@@ -242,17 +242,18 @@ export function toggleBreakpointAtLine(c
       })
     );
   };
 }
 
 export function addBreakpointAtLine(
   cx: Context,
   line: number,
-  shouldLog: ?boolean = false
+  shouldLog: boolean = false,
+  disabled: boolean = false
 ) {
   return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
     const state = getState();
     const source = getSelectedSource(state);
 
     if (!source || isEmptyLineInSource(state, line, source.id)) {
       return;
     }
@@ -263,17 +264,17 @@ export function addBreakpointAtLine(
       line
     };
 
     const options = {};
     if (shouldLog) {
       options.logValue = "displayName";
     }
 
-    return dispatch(addBreakpoint(cx, breakpointLocation, options));
+    return dispatch(addBreakpoint(cx, breakpointLocation, options, disabled));
   };
 }
 
 export function removeBreakpointsAtLine(
   cx: Context,
   sourceId: string,
   line: number
 ) {
--- a/devtools/client/debugger/src/components/Editor/index.js
+++ b/devtools/client/debugger/src/components/Editor/index.js
@@ -413,17 +413,17 @@ class Editor extends PureComponent<Props
     if (typeof sourceLine !== "number") {
       return;
     }
 
     if (ev.metaKey) {
       return continueToHere(cx, sourceLine);
     }
 
-    return addBreakpointAtLine(cx, sourceLine, ev.altKey);
+    return addBreakpointAtLine(cx, sourceLine, ev.altKey, ev.shiftKey);
   };
 
   onGutterContextMenu = (event: MouseEvent) => {
     return this.openMenu(event);
   };
 
   onClick(e: MouseEvent) {
     const { cx, selectedSource, jumpToMappedLocation } = this.props;
--- a/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js
@@ -15,61 +15,81 @@ async function disableBreakpoint(dbg, in
 }
 
 async function enableBreakpoint(dbg, index) {
   const enabled = waitForDispatch(dbg, "SET_BREAKPOINT");
   toggleBreakpoint(dbg, index);
   await enabled;
 }
 
+async function cleanupBreakpoints(dbg) {
+  clickElement(dbg, "gutter", 3);
+  clickElement(dbg, "gutter", 5);
+  await waitForBreakpointRemoved(dbg, "simple2", 3);
+  await waitForBreakpointRemoved(dbg, "simple2", 5);
+}
+
 // Test enabling and disabling a breakpoint using the check boxes
 add_task(async function() {
   const dbg = await initDebugger("doc-scripts.html", "simple2");
 
   // Create two breakpoints
   await selectSource(dbg, "simple2");
   await addBreakpoint(dbg, "simple2", 3);
   await addBreakpoint(dbg, "simple2", 5);
 
   // Disable the first one
   await disableBreakpoint(dbg, 0);
-  const bp1 = findBreakpoint(dbg, "simple2", 3);
+  let bp1 = findBreakpoint(dbg, "simple2", 3);
   let bp2 = findBreakpoint(dbg, "simple2", 5);
   is(bp1.disabled, true, "first breakpoint is disabled");
   is(bp2.disabled, false, "second breakpoint is enabled");
 
   // Disable and Re-Enable the second one
   await disableBreakpoint(dbg, 1);
   await enableBreakpoint(dbg, 1);
   bp2 = findBreakpoint(dbg, "simple2", 5);
   is(bp2.disabled, false, "second breakpoint is enabled");
-});
 
-// Test enabling and disabling a breakpoint using the context menu
-add_task(async function() {
-  const dbg = await initDebugger("doc-scripts.html");
+  // Cleanup
+  await cleanupBreakpoints(dbg);
+
+  // Test enabling and disabling a breakpoint using the context menu
   await selectSource(dbg, "simple2");
   await addBreakpoint(dbg, "simple2", 3);
   await addBreakpoint(dbg, "simple2", 5);
 
   assertEmptyLines(dbg, [1, 2]);
   assertBreakpointSnippet(dbg, 3, "return x + y;");
 
   rightClickElement(dbg, "breakpointItem", 2);
   const disableBreakpointDispatch = waitForDispatch(dbg, "SET_BREAKPOINT");
   selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableSelf);
   await disableBreakpointDispatch;
 
-  let bp1 = findBreakpoint(dbg, "simple2", 3);
-  let bp2 = findBreakpoint(dbg, "simple2", 5);
+  bp1 = findBreakpoint(dbg, "simple2", 3);
+  bp2 = findBreakpoint(dbg, "simple2", 5);
   is(bp1.disabled, true, "first breakpoint is disabled");
   is(bp2.disabled, false, "second breakpoint is enabled");
 
   rightClickElement(dbg, "breakpointItem", 2);
   const enableBreakpointDispatch = waitForDispatch(dbg, "SET_BREAKPOINT");
   selectContextMenuItem(dbg, selectors.breakpointContextMenu.enableSelf);
   await enableBreakpointDispatch;
 
   bp1 = findBreakpoint(dbg, "simple2", 3);
   bp2 = findBreakpoint(dbg, "simple2", 5);
   is(bp1.disabled, false, "first breakpoint is enabled");
   is(bp2.disabled, false, "second breakpoint is enabled");
+
+  // Cleanup
+  await cleanupBreakpoints(dbg);
+
+  // Test creation of disabled breakpoint with shift-click
+  await shiftClickElement(dbg, "gutter", 3);
+  await waitForBreakpoint(dbg, "simple2", 3);
+
+  const bp = findBreakpoint(dbg, "simple2", 3);
+  is(bp.disabled, true, "breakpoint is disabled");
+
+  // Cleanup
+  await cleanupBreakpoints(dbg);
 });
--- a/devtools/client/debugger/test/mochitest/helpers.js
+++ b/devtools/client/debugger/test/mochitest/helpers.js
@@ -445,16 +445,20 @@ function waitForBreakpointCount(dbg, cou
     state => dbg.selectors.getBreakpointCount() == count
   );
 }
 
 function waitForBreakpoint(dbg, url, line) {
   return waitForState(dbg, () => findBreakpoint(dbg, url, line));
 }
 
+function waitForBreakpointRemoved(dbg, url, line) {
+  return waitForState(dbg, () => !findBreakpoint(dbg, url, line));
+}
+
 /**
  * Waits for the debugger to be fully paused.
  *
  * @memberof mochitest/waits
  * @param {Object} dbg
  * @static
  */
 async function waitForPaused(dbg, url) {
@@ -1315,22 +1319,30 @@ function dblClickElement(dbg, elementNam
 
   return EventUtils.synthesizeMouseAtCenter(
     findElementWithSelector(dbg, selector),
     { clickCount: 2 },
     dbg.win
   );
 }
 
-function altClickElement(dbg, elementName, ...args) {
+function clickElementWithOptions(dbg, elementName, options, ...args) {
   const selector = getSelector(elementName, ...args);
   const el = findElementWithSelector(dbg, selector);
   el.scrollIntoView();
 
-  return EventUtils.synthesizeMouseAtCenter(el, { altKey: true }, dbg.win);
+  return EventUtils.synthesizeMouseAtCenter(el, options, dbg.win);
+}
+
+function altClickElement(dbg, elementName, ...args) {
+  return clickElementWithOptions(dbg, elementName, { altKey: true }, ...args);
+}
+
+function shiftClickElement(dbg, elementName, ...args) {
+  return clickElementWithOptions(dbg, elementName, { shiftKey: true }, ...args);
 }
 
 function rightClickElement(dbg, elementName, ...args) {
   const selector = getSelector(elementName, ...args);
   const doc = dbg.win.document;
   return rightClickEl(dbg, doc.querySelector(selector));
 }