Skip to content

Commit

Permalink
Bug 1050123 - Profiler Treeview: If arrow is the target of double cli…
Browse files Browse the repository at this point in the history
…ck, children toggle three times (on click #1, click #2 and dblclick events). Ignore the dblclick on arrow. r=vp

UltraBlame original commit: b5345b8463af3140d9c4ca24c40503c35901de93
  • Loading branch information
marco-c committed Sep 29, 2019
1 parent 4b53832 commit 887c774
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions browser/devtools/profiler/test/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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: []
}]
}]
};
7 changes: 6 additions & 1 deletion browser/devtools/shared/widgets/AbstractTreeItem.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ AbstractTreeItem.prototype = {


_onDoubleClick: function(e) {
this._onArrowClick(e);


if (!e.target.classList.contains("arrow")) {
this._onArrowClick(e);
}

this.focus();
},

Expand Down

0 comments on commit 887c774

Please sign in to comment.