From 887c774f50099306710da1604b81421c476e5bc2 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sun, 29 Sep 2019 13:24:31 +0000 Subject: [PATCH] Bug 1050123 - Profiler Treeview: If arrow is the target of double click, children toggle three times (on click #1, click #2 and dblclick events). Ignore the dblclick on arrow. r=vp UltraBlame original commit: b5345b8463af3140d9c4ca24c40503c35901de93 --- browser/devtools/profiler/test/browser.ini | 1 + .../test/browser_profiler_tree-abstract-04.js | 68 +++++++++++++++++++ .../shared/widgets/AbstractTreeItem.jsm | 7 +- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 browser/devtools/profiler/test/browser_profiler_tree-abstract-04.js diff --git a/browser/devtools/profiler/test/browser.ini b/browser/devtools/profiler/test/browser.ini index 31e4f0817a20..4ef4e289a7b4 100644 --- a/browser/devtools/profiler/test/browser.ini +++ b/browser/devtools/profiler/test/browser.ini @@ -93,6 +93,7 @@ skip-if = true # Bug 1047124 [browser_profiler_tree-abstract-01.js] [browser_profiler_tree-abstract-02.js] [browser_profiler_tree-abstract-03.js] +[browser_profiler_tree-abstract-04.js] [browser_profiler_tree-frame-node.js] [browser_profiler_tree-model-01.js] [browser_profiler_tree-model-02.js] diff --git a/browser/devtools/profiler/test/browser_profiler_tree-abstract-04.js b/browser/devtools/profiler/test/browser_profiler_tree-abstract-04.js new file mode 100644 index 000000000000..bdf94adaa3c9 --- /dev/null +++ b/browser/devtools/profiler/test/browser_profiler_tree-abstract-04.js @@ -0,0 +1,68 @@ + + + + + + + +let { AbstractTreeItem } = Cu.import("resource:///modules/devtools/AbstractTreeItem.jsm", {}); +let { Heritage } = Cu.import("resource:///modules/devtools/ViewHelpers.jsm", {}); + +let test = Task.async(function*() { + let container = document.createElement("vbox"); + gBrowser.selectedBrowser.parentNode.appendChild(container); + + + + let treeRoot = new MyCustomTreeItem(gDataSrc, { parent: null }); + treeRoot.attachTo(container); + + let originalTreeRootExpanded = treeRoot.expanded; + info("Double clicking on the root item arrow and waiting for focus event."); + let receivedFocusEvent = treeRoot.once("focus"); + EventUtils.sendMouseEvent({ type: "dblclick" }, treeRoot.target.querySelector(".arrow")); + + yield receivedFocusEvent; + is(treeRoot.expanded, originalTreeRootExpanded, + "A double click on the arrow was ignored."); + + container.remove(); + finish(); +}); + +function MyCustomTreeItem(dataSrc, properties) { + AbstractTreeItem.call(this, properties); + this.itemDataSrc = dataSrc; +} + +MyCustomTreeItem.prototype = Heritage.extend(AbstractTreeItem.prototype, { + _displaySelf: function(document, arrowNode) { + let node = document.createElement("hbox"); + node.MozMarginStart = (this.level * 10) + "px"; + node.appendChild(arrowNode); + node.appendChild(document.createTextNode(this.itemDataSrc.label)); + return node; + }, + _populateSelf: function(children) { + for (let childDataSrc of this.itemDataSrc.children) { + children.push(new MyCustomTreeItem(childDataSrc, { + parent: this, + level: this.level + 1 + })); + } + } +}); + +let gDataSrc = { + label: "root", + children: [{ + label: "foo", + children: [] + }, { + label: "bar", + children: [{ + label: "baz", + children: [] + }] + }] +}; diff --git a/browser/devtools/shared/widgets/AbstractTreeItem.jsm b/browser/devtools/shared/widgets/AbstractTreeItem.jsm index 5f7a61ba5b97..cdc8511547d3 100644 --- a/browser/devtools/shared/widgets/AbstractTreeItem.jsm +++ b/browser/devtools/shared/widgets/AbstractTreeItem.jsm @@ -427,7 +427,12 @@ AbstractTreeItem.prototype = { _onDoubleClick: function(e) { - this._onArrowClick(e); + + + if (!e.target.classList.contains("arrow")) { + this._onArrowClick(e); + } + this.focus(); },