Bug 1555333 - Toggle skipPausing when adding or enabling a breakpoint via reducers r=jlast
authorDavid Walsh <dwalsh@mozilla.com>
Tue, 27 Aug 2019 20:51:10 +0000
changeset 490291 c50fea61ff7079b8efc1b70a4f6c60ea24dc0b15
parent 490290 14a7894321177ca9c0e4b6fb7347e3f281fa6e92
child 490292 3076039dfbf4be60d0d90a011298770f2f2ec930
push id93774
push userdwalsh@mozilla.com
push dateTue, 27 Aug 2019 21:39:43 +0000
treeherderautoland@c50fea61ff70 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1555333
milestone70.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 1555333 - Toggle skipPausing when adding or enabling a breakpoint via reducers r=jlast Differential Revision: https://phabricator.services.mozilla.com/D43512
devtools/client/debugger/src/actions/pause/index.js
devtools/client/debugger/src/actions/pause/skipPausing.js
devtools/client/debugger/src/components/SecondaryPanes/DOMMutationBreakpoints.js
devtools/client/debugger/src/reducers/pause.js
devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js
--- a/devtools/client/debugger/src/actions/pause/index.js
+++ b/devtools/client/debugger/src/actions/pause/index.js
@@ -21,12 +21,12 @@ export {
 export { fetchScopes } from "./fetchScopes";
 export { paused } from "./paused";
 export { resumed } from "./resumed";
 export { continueToHere } from "./continueToHere";
 export { breakOnNext } from "./breakOnNext";
 export { mapFrames } from "./mapFrames";
 export { pauseOnExceptions } from "./pauseOnExceptions";
 export { selectFrame } from "./selectFrame";
-export { toggleSkipPausing } from "./skipPausing";
+export { toggleSkipPausing, setSkipPausing } from "./skipPausing";
 export { toggleMapScopes } from "./mapScopes";
 export { setExpandedScope } from "./expandScopes";
 export { generateInlinePreview } from "./inlinePreview";
--- a/devtools/client/debugger/src/actions/pause/skipPausing.js
+++ b/devtools/client/debugger/src/actions/pause/skipPausing.js
@@ -13,8 +13,24 @@ import { getSkipPausing } from "../../se
  */
 export function toggleSkipPausing() {
   return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
     const skipPausing = !getSkipPausing(getState());
     await client.setSkipPausing(skipPausing);
     dispatch({ type: "TOGGLE_SKIP_PAUSING", skipPausing });
   };
 }
+
+/**
+ * @memberof actions/pause
+ * @static
+ */
+export function setSkipPausing(skipPausing: boolean) {
+  return async ({ dispatch, client, getState, sourceMaps }: ThunkArgs) => {
+    const currentlySkipping = getSkipPausing(getState());
+    if (currentlySkipping === skipPausing) {
+      return;
+    }
+
+    await client.setSkipPausing(skipPausing);
+    dispatch({ type: "TOGGLE_SKIP_PAUSING", skipPausing });
+  };
+}
--- a/devtools/client/debugger/src/components/SecondaryPanes/DOMMutationBreakpoints.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/DOMMutationBreakpoints.js
@@ -26,41 +26,52 @@ import type { DOMMutationBreakpoint } fr
 
 type Props = {
   breakpoints: DOMMutationBreakpoint[],
   openElementInInspector: typeof actions.openElementInInspectorCommand,
   highlightDomElement: typeof actions.highlightDomElement,
   unHighlightDomElement: typeof actions.unHighlightDomElement,
   deleteBreakpoint: typeof deleteDOMMutationBreakpoint,
   toggleBreakpoint: typeof toggleDOMMutationBreakpointState,
+  setSkipPausing: typeof actions.setSkipPausing,
 };
 
 const localizationTerms = {
   subtree: L10N.getStr("domMutationTypes.subtree"),
   attribute: L10N.getStr("domMutationTypes.attribute"),
   removal: L10N.getStr("domMutationTypes.removal"),
 };
 
 class DOMMutationBreakpointsContents extends Component<Props> {
+  handleBreakpoint(breakpointId, shouldEnable) {
+    const { toggleBreakpoint, setSkipPausing } = this.props;
+
+    // The user has enabled a mutation breakpoint so we should no
+    // longer skip pausing
+    if (shouldEnable) {
+      setSkipPausing(false);
+    }
+    toggleBreakpoint(breakpointId, shouldEnable);
+  }
+
   renderItem(breakpoint: DOMMutationBreakpoint) {
     const {
       openElementInInspector,
       highlightDomElement,
       unHighlightDomElement,
-      toggleBreakpoint,
       deleteBreakpoint,
     } = this.props;
     const { enabled, id: breakpointId, nodeFront, mutationType } = breakpoint;
 
     return (
       <li key={breakpoint.id}>
         <input
           type="checkbox"
           checked={enabled}
-          onChange={() => toggleBreakpoint(breakpointId, !enabled)}
+          onChange={() => this.handleBreakpoint(breakpointId, !enabled)}
         />
         <div className="dom-mutation-info">
           <div className="dom-mutation-label">
             {Rep({
               object: translateNodeFrontToGrip(nodeFront),
               mode: MODE.TINY,
               onDOMNodeClick: () => openElementInInspector(nodeFront),
               onInspectIconClick: () => openElementInInspector(nodeFront),
@@ -118,23 +129,25 @@ const DOMMutationBreakpointsPanel = conn
 
 class DomMutationBreakpoints extends Component<Props> {
   render() {
     return (
       <DOMMutationBreakpointsPanel
         openElementInInspector={this.props.openElementInInspector}
         highlightDomElement={this.props.highlightDomElement}
         unHighlightDomElement={this.props.unHighlightDomElement}
+        setSkipPausing={this.props.setSkipPausing}
       />
     );
   }
 }
 
 export default connect(
   undefined,
   {
     // the debugger-specific action bound to the debugger store
     // since there is no `storeKey`
     openElementInInspector: actions.openElementInInspectorCommand,
     highlightDomElement: actions.highlightDomElement,
     unHighlightDomElement: actions.unHighlightDomElement,
+    setSkipPausing: actions.setSkipPausing,
   }
 )(DomMutationBreakpoints);
--- a/devtools/client/debugger/src/reducers/pause.js
+++ b/devtools/client/debugger/src/reducers/pause.js
@@ -338,16 +338,30 @@ function update(
           [action.mainThread.actor]: {
             ...getThreadPauseState(state, action.mainThread.actor),
             ...resumedPauseState,
           },
         },
       };
     }
 
+    // Disable skipPausing if a breakpoint is enabled or added
+    case "SET_BREAKPOINT": {
+      return action.breakpoint.disabled
+        ? state
+        : { ...state, skipPausing: false };
+    }
+
+    case "UPDATE_EVENT_LISTENERS":
+    case "REMOVE_BREAKPOINT":
+    case "SET_XHR_BREAKPOINT":
+    case "ENABLE_XHR_BREAKPOINT": {
+      return { ...state, skipPausing: false };
+    }
+
     case "TOGGLE_SKIP_PAUSING": {
       const { skipPausing } = action;
       prefs.skipPausing = skipPausing;
 
       return { ...state, skipPausing };
     }
 
     case "TOGGLE_MAP_SCOPES": {
--- a/devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js
@@ -2,16 +2,29 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 function skipPausing(dbg) {
   clickElementWithSelector(dbg, ".command-bar-skip-pausing");
   return waitForState(dbg, state => dbg.selectors.getSkipPausing());
 }
 
+function toggleBreakpoint(dbg, index) {
+  const breakpoints = findAllElements(dbg, "breakpointItems");
+  const bp = breakpoints[index];
+  const input = bp.querySelector("input");
+  input.click();
+}
+
+async function disableBreakpoint(dbg, index) {
+  const disabled = waitForDispatch(dbg, "SET_BREAKPOINT");
+  toggleBreakpoint(dbg, index);
+  await disabled;
+}
+
 /*
  * Tests toggling the skip pausing button and
  * invoking functions without pausing.
  */
 
 add_task(async function() {
   const dbg = await initDebugger("doc-scripts.html");
   await selectSource(dbg, "simple3");
@@ -20,9 +33,19 @@ add_task(async function() {
   await skipPausing(dbg);
   let res = await invokeInTab("simple");
   is(res, 3, "simple() successfully completed");
 
   info("Reload and invoke again");
   await reload(dbg, "simple3");
   res = await invokeInTab("simple");
   is(res, 3, "simple() successfully completed");
+
+  info("Adding a breakpoint disables skipPausing");
+  await addBreakpoint(dbg, "simple3", 3);
+  await waitForState(dbg, state => !state.skipPausing);
+
+  info("Enabling a breakpoint disables skipPausing");
+  await skipPausing(dbg);
+  await disableBreakpoint(dbg, 0);
+  await toggleBreakpoint(dbg, 0);
+  await waitForState(dbg, state => !state.skipPausing);
 });