Bug 1577081 - Make blackbox work from frame context menu r=jlast
authorDavid Walsh <dwalsh@mozilla.com>
Thu, 29 Aug 2019 20:50:10 +0000
changeset 551215 61e550aaa29d07a4e5a57dd75be5eaa7e8c1194c
parent 551214 6390dc77aaf0a3cb47f40227e8e0da858facdcff
child 551216 85d8c19fcc3c712b4c3515568a08688d968f7d7f
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1577081
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 1577081 - Make blackbox work from frame context menu r=jlast Differential Revision: https://phabricator.services.mozilla.com/D43973
devtools/client/debugger/src/components/SecondaryPanes/Frames/Frame.js
devtools/client/debugger/src/components/SecondaryPanes/Frames/FrameMenu.js
devtools/client/debugger/src/components/SecondaryPanes/Frames/Group.js
devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/Frame.spec.js
devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/FrameMenu.spec.js
devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/Group.spec.js
--- a/devtools/client/debugger/src/components/SecondaryPanes/Frames/Frame.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Frames/Frame.js
@@ -87,22 +87,24 @@ export default class FrameComponent exte
 
   onContextMenu(event: SyntheticMouseEvent<HTMLElement>) {
     const {
       frame,
       copyStackTrace,
       toggleFrameworkGrouping,
       toggleBlackBox,
       frameworkGroupingOn,
+      cx,
     } = this.props;
     FrameMenu(
       frame,
       frameworkGroupingOn,
       { copyStackTrace, toggleFrameworkGrouping, toggleBlackBox },
-      event
+      event,
+      cx
     );
   }
 
   onMouseDown(
     e: SyntheticMouseEvent<HTMLElement>,
     frame: Frame,
     selectedFrame: Frame
   ) {
--- a/devtools/client/debugger/src/components/SecondaryPanes/Frames/FrameMenu.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Frames/FrameMenu.js
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/>. */
 
 // @flow
 import { showMenu } from "devtools-contextmenu";
 import { copyToTheClipboard } from "../../../utils/clipboard";
-import type { ContextMenuItem, Frame } from "../../../types";
+import type { ContextMenuItem, Frame, ThreadContext } from "../../../types";
 import { kebabCase } from "lodash";
 
 const blackboxString = "blackboxContextItem.blackbox";
 const unblackboxString = "blackboxContextItem.unblackbox";
 
 function formatMenuElement(
   labelString: string,
   click: Function,
@@ -42,29 +42,32 @@ function toggleFrameworkGroupingElement(
 ) {
   const actionType = frameworkGroupingOn
     ? "framework.disableGrouping"
     : "framework.enableGrouping";
 
   return formatMenuElement(actionType, () => toggleFrameworkGrouping());
 }
 
-function blackBoxSource(source, toggleBlackBox) {
+function blackBoxSource(cx, source, toggleBlackBox) {
   const toggleBlackBoxString = source.isBlackBoxed
     ? unblackboxString
     : blackboxString;
 
-  return formatMenuElement(toggleBlackBoxString, () => toggleBlackBox(source));
+  return formatMenuElement(toggleBlackBoxString, () =>
+    toggleBlackBox(cx, source)
+  );
 }
 
 export default function FrameMenu(
   frame: Frame,
   frameworkGroupingOn: boolean,
   callbacks: Object,
-  event: SyntheticMouseEvent<HTMLElement>
+  event: SyntheticMouseEvent<HTMLElement>,
+  cx: ThreadContext
 ) {
   event.stopPropagation();
   event.preventDefault();
 
   const menuOptions = [];
 
   const source = frame.source;
 
@@ -72,17 +75,17 @@ export default function FrameMenu(
     callbacks.toggleFrameworkGrouping,
     frameworkGroupingOn
   );
   menuOptions.push(toggleFrameworkElement);
 
   if (source) {
     const copySourceUri2 = copySourceElement(source.url);
     menuOptions.push(copySourceUri2);
-    menuOptions.push(blackBoxSource(source, callbacks.toggleBlackBox));
+    menuOptions.push(blackBoxSource(cx, source, callbacks.toggleBlackBox));
   }
 
   const copyStackTraceItem = copyStackTraceElement(callbacks.copyStackTrace);
 
   menuOptions.push(copyStackTraceItem);
 
   showMenu(event, menuOptions);
 }
--- a/devtools/client/debugger/src/components/SecondaryPanes/Frames/Group.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Frames/Group.js
@@ -68,23 +68,25 @@ export default class Group extends Compo
 
   onContextMenu(event: SyntheticMouseEvent<HTMLElement>) {
     const {
       group,
       copyStackTrace,
       toggleFrameworkGrouping,
       toggleBlackBox,
       frameworkGroupingOn,
+      cx,
     } = this.props;
     const frame = group[0];
     FrameMenu(
       frame,
       frameworkGroupingOn,
       { copyStackTrace, toggleFrameworkGrouping, toggleBlackBox },
-      event
+      event,
+      cx
     );
   }
 
   toggleFrames = (event: SyntheticMouseEvent<HTMLElement>) => {
     event.stopPropagation();
     this.setState(prevState => ({ expanded: !prevState.expanded }));
   };
 
--- a/devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/Frame.spec.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/Frame.spec.js
@@ -110,25 +110,31 @@ describe("Frame", () => {
       const mockEvent = "mockEvent";
       component.simulate("contextmenu", mockEvent);
 
       expect(FrameMenu).toHaveBeenCalledTimes(0);
     });
 
     it("calls FrameMenu on right click", () => {
       const { component, props } = render();
-      const { copyStackTrace, toggleFrameworkGrouping, toggleBlackBox } = props;
+      const {
+        copyStackTrace,
+        toggleFrameworkGrouping,
+        toggleBlackBox,
+        cx,
+      } = props;
       const mockEvent = "mockEvent";
       component.simulate("contextmenu", mockEvent);
 
       expect(FrameMenu).toHaveBeenCalledWith(
         props.frame,
         props.frameworkGroupingOn,
         {
           copyStackTrace,
           toggleFrameworkGrouping,
           toggleBlackBox,
         },
-        mockEvent
+        mockEvent,
+        cx
       );
     });
   });
 });
--- a/devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/FrameMenu.spec.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/FrameMenu.spec.js
@@ -4,17 +4,21 @@
 
 // @flow
 
 import FrameMenu from "../FrameMenu";
 import { kebabCase } from "lodash";
 
 import { showMenu } from "devtools-contextmenu";
 import { copyToTheClipboard } from "../../../../utils/clipboard";
-import { makeMockFrame, makeMockSource } from "../../../../utils/test-mockup";
+import {
+  makeMockFrame,
+  makeMockSource,
+  mockthreadcx,
+} from "../../../../utils/test-mockup";
 
 jest.mock("devtools-contextmenu", () => ({ showMenu: jest.fn() }));
 jest.mock("../../../../utils/clipboard", () => ({
   copyToTheClipboard: jest.fn(),
 }));
 
 function generateMockId(labelString) {
   const label = L10N.getStr(labelString);
@@ -48,55 +52,67 @@ describe("FrameMenu", () => {
   });
 
   it("sends three element in menuOpts to showMenu if source is present", () => {
     const sourceId = generateMockId("copySourceUri2");
     const stacktraceId = generateMockId("copyStackTrace");
     const frameworkGroupingId = generateMockId("framework.enableGrouping");
     const blackBoxId = generateMockId("sourceFooter.blackbox");
 
-    FrameMenu(mockFrame, frameworkGroupingOn, callbacks, mockEvent);
+    FrameMenu(
+      mockFrame,
+      frameworkGroupingOn,
+      callbacks,
+      mockEvent,
+      mockthreadcx
+    );
 
     const receivedArray = showMenu.mock.calls[0][1];
     expect(showMenu).toHaveBeenCalledWith(mockEvent, receivedArray);
     const receivedArrayIds = receivedArray.map(item => item.id);
     expect(receivedArrayIds).toEqual([
       frameworkGroupingId,
       sourceId,
       blackBoxId,
       stacktraceId,
     ]);
   });
 
   it("sends one element in menuOpts without source", () => {
     const stacktraceId = generateMockId("copyStackTrace");
     const frameworkGrouping = generateMockId("framework.enableGrouping");
 
-    FrameMenu(emptyFrame, frameworkGroupingOn, callbacks, mockEvent);
+    FrameMenu(
+      emptyFrame,
+      frameworkGroupingOn,
+      callbacks,
+      mockEvent,
+      mockthreadcx
+    );
 
     const receivedArray = showMenu.mock.calls[0][1];
     expect(showMenu).toHaveBeenCalledWith(mockEvent, receivedArray);
     const receivedArrayIds = receivedArray.map(item => item.id);
     expect(receivedArrayIds).toEqual([frameworkGrouping, stacktraceId]);
   });
 
   it("uses the disableGrouping text if frameworkGroupingOn is false", () => {
     const stacktraceId = generateMockId("copyStackTrace");
     const frameworkGrouping = generateMockId("framework.disableGrouping");
 
-    FrameMenu(emptyFrame, true, callbacks, mockEvent);
+    FrameMenu(emptyFrame, true, callbacks, mockEvent, mockthreadcx);
 
     const receivedArray = showMenu.mock.calls[0][1];
     const receivedArrayIds = receivedArray.map(item => item.id);
     expect(receivedArrayIds).toEqual([frameworkGrouping, stacktraceId]);
   });
 
   it("uses the enableGrouping text if frameworkGroupingOn is true", () => {
     const stacktraceId = generateMockId("copyStackTrace");
     const frameworkGrouping = generateMockId("framework.enableGrouping");
 
-    FrameMenu(emptyFrame, false, callbacks, mockEvent);
+    FrameMenu(emptyFrame, false, callbacks, mockEvent, mockthreadcx);
 
     const receivedArray = showMenu.mock.calls[0][1];
     const receivedArrayIds = receivedArray.map(item => item.id);
     expect(receivedArrayIds).toEqual([frameworkGrouping, stacktraceId]);
   });
 });
--- a/devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/Group.spec.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Frames/tests/Group.spec.js
@@ -108,25 +108,31 @@ describe("Group", () => {
       const mockEvent = "mockEvent";
       component.simulate("contextmenu", mockEvent);
 
       expect(FrameMenu).toHaveBeenCalledTimes(0);
     });
 
     it("calls FrameMenu on right click", () => {
       const { component, props } = render();
-      const { copyStackTrace, toggleFrameworkGrouping, toggleBlackBox } = props;
+      const {
+        copyStackTrace,
+        toggleFrameworkGrouping,
+        toggleBlackBox,
+        cx,
+      } = props;
       const mockEvent = "mockEvent";
       component.simulate("contextmenu", mockEvent);
 
       expect(FrameMenu).toHaveBeenCalledWith(
         props.group[0],
         props.frameworkGroupingOn,
         {
           copyStackTrace,
           toggleFrameworkGrouping,
           toggleBlackBox,
         },
-        mockEvent
+        mockEvent,
+        cx
       );
     });
   });
 });