From 31be15ff621fed9f83f1a91b432c77aa413b2470 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Tue, 20 Aug 2019 17:11:12 +0000 Subject: [PATCH] Bug 1574831 - Pass the object to onDOMNodeMouseOut in the reps. r=nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D42444 --HG-- extra : moz-landing-system : lando --- .../packages/devtools-reps/src/reps/element-node.js | 2 +- .../packages/devtools-reps/src/reps/tests/element-node.js | 1 + .../debugger/packages/devtools-reps/src/reps/tests/event.js | 1 + .../packages/devtools-reps/src/reps/tests/grip-array.js | 3 +++ .../packages/devtools-reps/src/reps/tests/grip-map-entry.js | 2 ++ .../packages/devtools-reps/src/reps/tests/grip-map.js | 6 ++++++ .../debugger/packages/devtools-reps/src/reps/tests/grip.js | 2 ++ .../packages/devtools-reps/src/reps/tests/promise.js | 1 + .../packages/devtools-reps/src/reps/tests/text-node.js | 1 + .../debugger/packages/devtools-reps/src/reps/text-node.js | 2 +- devtools/client/shared/components/reps/reps.js | 4 ++-- 11 files changed, 21 insertions(+), 4 deletions(-) diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/element-node.js b/devtools/client/debugger/packages/devtools-reps/src/reps/element-node.js index 5db082a017a4..3278921544bd 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/element-node.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/element-node.js @@ -65,7 +65,7 @@ function ElementNode(props) { if (onDOMNodeMouseOut) { Object.assign(baseConfig, { - onMouseOut: onDOMNodeMouseOut, + onMouseOut: _ => onDOMNodeMouseOut(object), }); } diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/element-node.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/element-node.js index 21e629151748..4f2e79857d92 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/element-node.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/element-node.js @@ -160,6 +160,7 @@ describe("ElementNode - Node", () => { renderedComponent.simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(1); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toEqual(stub); }); it("calls the expected function when mouseover is fired on Rep", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/event.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/event.js index 130ae150d81c..cf792e509f6d 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/event.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/event.js @@ -126,6 +126,7 @@ describe("Event - mouse event", () => { node.simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(1); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toEqual(grips[0]); }); it("calls the expected function when mouseover is fired on Rep", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-array.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-array.js index b98a5a2d9fa1..e06d20a82dcf 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-array.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-array.js @@ -386,6 +386,9 @@ describe("GripArray - NodeList", () => { node.at(2).simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(3); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toBe(grips[0]); + expect(onDOMNodeMouseOut.mock.calls[1][0]).toBe(grips[1]); + expect(onDOMNodeMouseOut.mock.calls[2][0]).toBe(grips[2]); }); it("calls the expected function on click", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map-entry.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map-entry.js index a1883f5b71b6..0297b6439a33 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map-entry.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map-entry.js @@ -147,6 +147,7 @@ describe("GripMapEntry - complex", () => { node.simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(1); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toEqual(stub); node.simulate("mouseover"); expect(onDOMNodeMouseOver.mock.calls).toHaveLength(1); @@ -172,6 +173,7 @@ describe("GripMapEntry - complex", () => { node.simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(2); + expect(onDOMNodeMouseOut.mock.calls[1][0]).toEqual(stub); node.simulate("mouseover"); expect(onDOMNodeMouseOver.mock.calls).toHaveLength(2); diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map.js index 083037d845e3..60645d6cf908 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip-map.js @@ -236,6 +236,9 @@ describe("GripMap - Node-keyed entries", () => { node.at(2).simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(3); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toBe(grips[0]); + expect(onDOMNodeMouseOut.mock.calls[1][0]).toBe(grips[1]); + expect(onDOMNodeMouseOut.mock.calls[2][0]).toBe(grips[2]); }); it("calls the expected function on click", () => { @@ -292,6 +295,9 @@ describe("GripMap - Node-valued entries", () => { node.at(2).simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(3); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toBe(grips[0]); + expect(onDOMNodeMouseOut.mock.calls[1][0]).toBe(grips[1]); + expect(onDOMNodeMouseOut.mock.calls[2][0]).toBe(grips[2]); }); it("calls the expected function on click", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip.js index e69c004ad953..d1ed178d44b8 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/grip.js @@ -380,6 +380,8 @@ describe("Grip - Object with connected nodes", () => { node.at(1).simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(2); + expect(onDOMNodeMouseOut.mock.calls[0][0]).toBe(grips[0]); + expect(onDOMNodeMouseOut.mock.calls[1][0]).toBe(grips[1]); }); it("calls the expected function on click", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/promise.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/promise.js index 31d12da2111c..f4197a796436 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/promise.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/promise.js @@ -129,6 +129,7 @@ describe("Promise - fulfilled with node", () => { node.simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(1); + expect(onDOMNodeMouseOut).toHaveBeenCalledWith(grips[0]); }); it("no inspect icon when the node is not connected to the DOM tree", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/text-node.js b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/text-node.js index 9f70151c6834..3577985653d4 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/tests/text-node.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/tests/text-node.js @@ -70,6 +70,7 @@ describe("TextNode", () => { wrapper.simulate("mouseout"); expect(onDOMNodeMouseOut.mock.calls).toHaveLength(1); + expect(onDOMNodeMouseOut).toHaveBeenCalledWith(object); }); it("displays a button when the node is connected", () => { diff --git a/devtools/client/debugger/packages/devtools-reps/src/reps/text-node.js b/devtools/client/debugger/packages/devtools-reps/src/reps/text-node.js index 978b0abbc610..10ea8c98e603 100644 --- a/devtools/client/debugger/packages/devtools-reps/src/reps/text-node.js +++ b/devtools/client/debugger/packages/devtools-reps/src/reps/text-node.js @@ -49,7 +49,7 @@ function TextNode(props) { if (onDOMNodeMouseOut) { Object.assign(baseConfig, { - onMouseOut: onDOMNodeMouseOut, + onMouseOut: _ => onDOMNodeMouseOut(grip), }); } diff --git a/devtools/client/shared/components/reps/reps.js b/devtools/client/shared/components/reps/reps.js index 8a2426ce8280..5b792d222646 100644 --- a/devtools/client/shared/components/reps/reps.js +++ b/devtools/client/shared/components/reps/reps.js @@ -6925,7 +6925,7 @@ function ElementNode(props) { if (onDOMNodeMouseOut) { Object.assign(baseConfig, { - onMouseOut: onDOMNodeMouseOut + onMouseOut: _ => onDOMNodeMouseOut(object) }); } @@ -7112,7 +7112,7 @@ function TextNode(props) { if (onDOMNodeMouseOut) { Object.assign(baseConfig, { - onMouseOut: onDOMNodeMouseOut + onMouseOut: _ => onDOMNodeMouseOut(grip) }); }