Files
palemoon27/devtools/client/shared/test/browser_treeWidget_mouse_interaction.js
T
roytam1 d6c5650b54 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1189759 - Part 1: Implement <xul:menuitem endimage> as a way to display an image at the end of a menu item; r=jaws (eb66e2b142)
- bits of Bug 880164 - Australis toolbar buttons contextual menu in toolbar, palette and customize mode (601529fa02)
- complete allTabs removal  initiate accidentally in  1228627 (11526f9be2)
- Bug 1189759 - Part 2: Add sound playing and muted icons to the all tabs menu; r=jaws (b3780a4080)
- Bug 1204845 - Remove the menuitem-iconic-both binding. r=enndeakin (1a6b49137f)
- Bug 897751 - Tab close button's DoubleClick protection handler leaks. r=mano (598ffd6ea0)
- Bug 1059600 - Set the URI as the initial tab label for javascript links opened in new tabs. r=gijs (a888e89683)
- Bug 1247920 - Remove tabs' visibleLabel property and TabLabelModified event, backing out bug 943820. r=gijs (f2a8c6c5b6)
- Bug 1196762 - Part 2: PrefsProvider and PlacesProvider messaging integration in RemoteAboutNewTab r=Mardak (40f298de12)
- Bug 1210478 - Add Meta URL resolution in RemoteNewTabLocation r=mconley (a9a7b774b2)
- Bug 1218996 - Fuse aboutNewTabService and RemoteNewTabLocation and return resource URLS r=marcosc (42f6909cc8)
- Bug 1218996 - Remove now redundant messaging code for remote newtab r=marcosc (50de90e6c9)
- Bug 1214287 - 2-4% linux64/win7/8 ts_paint regression on inbound (v.44) seen on Oct 12, 2015 from rev 3012b7a2c97c r=mconley (f7d4224141)
- assorted fixes to make newtab work (d5b208fc72)
- Bug 1169179 - Run mozscreenshots as a mochitest-browser-chrome test. r=felipe,glandium (6a9c3c896d)
- Bug 1216979 - Add ACCEL+ALT+R key binding to reload WebIDE. r=jryans (c7afde0f46)
- Bug 1204127 - Clean up paths added after migration. r=ochameau (9e35211636)
- Bug 1029371 - Make style editor media sidebar interact with media sidebar. r=bgrins r=paul r=mgoodwin (c166b888cb)
- Bug 1055333 - Enable last styleeditor e10s tests;r=ejpbruel (768bc3948b)
- Bug 1192486 - make completion work in any selected style editor; r=mratcliffe (fde809a65e)
- Bug 1206463 - Eslint cleanup for source editor r=mratcliffe (b8a2b7f0e7)
- Bug 1232786 - Convert JS tests to use open2 within devtools/ (r=sicking) (3c76f148d8)
- Bug 1235953 - Refactor responsive mode tests to use add_task to not use CPOWs and make sure they all wait for the off event. r=ochameau (ad4374ca81)
- Bug 1240183 - make styleeditor eslint-clean; r=pbro (37f17595ca)
- Bug 1162848 - Make console 'clear' shortcut ctrl+shift+l on Windows / Linux;r=jryans (1870519951)
- Bug 1245462 - Replace usages of gDevTools.jsm by module imports. r=jryans (7f967d5410)
- Bug 1244514 - webconsole.js eslint: fix spacing and line length; r=linclark (c98e3aeb07)
- Bug 1246188 - Make webconsole.js ESLint-clean. r=lclark (7dec42e75f)
- Bug 1249714 - Use jsterm.focus instead of inputNode.focus;r=linclark (60238ce0bd)
- Bug 1249715 - Split jsterm into different file than webconsole.js;r=linclark (b4560b21b4)
- Bug 1249714 - Use jsterm.focus instead of inputNode.focus;r=linclark (a01b4348f4)
- Bug 1248301 - Do not cause a horizontal scrollbar to appear in the console when it overflows vertically;r=vporof (2c86ffacbe)
- Bug 1228032 - restore chrome://global/skin/ where chrome://browser/skin/ was removed, r=jryans (5609017a31)
- Bug 1239437 - Delegate to empty, new responsive UI tool if enabled. r=pbrosset (e131d71fa6)
- Bug 1239437 - Add a basic viewport frame. r=pbrosset (82759cdcc3)
- Bug 1239437 - Hide iframe border. r=pbrosset (5668bd6171)
- Bug 1239437 - Stir in React and Redux. r=pbrosset,jlongster (c6ef09a7f7)
- Bug 1246733 - Remove stylesheet references of 'devtools/skin/common.css' and instead import it in theme files;r=ntim,r=ochameau (dd5c660185)
- Bug 1204429 - Part 1: Collect primitive counts information. r=vporof (bdaaad5c20)
- Bug 1204429 - Part 2: Add tests for counting number of primitives in WebGL draw functions. r=vporof (1a093ad855)
- Bug 1226245 - Make CallWatcher generic, r=jsantell (5771c8a173)
2024-01-25 12:03:08 +08:00

137 lines
4.2 KiB
JavaScript

/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that mouse interaction works fine with tree widget
const TEST_URI = "data:text/html;charset=utf-8,<head>" +
"<link rel='stylesheet' type='text/css' href='chrome://devtools/skin/widg" +
"ets.css'></head><body><div></div><span></span></body>";
const {TreeWidget} = require("devtools/client/shared/widgets/TreeWidget");
const Promise = require("promise");
add_task(function*() {
yield addTab("about:blank");
let [host, win, doc] = yield createHost("bottom", TEST_URI);
let tree = new TreeWidget(doc.querySelector("div"), {
defaultType: "store"
});
populateTree(tree, doc);
yield testMouseInteraction(tree);
tree.destroy();
host.destroy();
gBrowser.removeCurrentTab();
});
function populateTree(tree, doc) {
tree.add([{
id: "level1",
label: "Level 1"
}, {
id: "level2-1",
label: "Level 2"
}, {
id: "level3-1",
label: "Level 3 - Child 1",
type: "dir"
}]);
tree.add(["level1", "level2-1", { id: "level3-2", label: "Level 3 - Child 2"}]);
tree.add(["level1", "level2-1", { id: "level3-3", label: "Level 3 - Child 3"}]);
tree.add(["level1", {
id: "level2-2",
label: "Level 2.1"
}, {
id: "level3-1",
label: "Level 3.1"
}]);
tree.add([{
id: "level1",
label: "Level 1"
}, {
id: "level2",
label: "Level 2"
}, {
id: "level3",
label: "Level 3",
type: "js"
}]);
tree.add(["level1.1", "level2", {id: "level3", type: "url"}]);
// Adding a new non text item in the tree.
let node = doc.createElement("div");
node.textContent = "Foo Bar";
node.className = "foo bar";
tree.add([{
id: "level1.2",
node: node,
attachment: {
foo: "bar"
}
}]);
}
// Sends a click event on the passed DOM node in an async manner
function click(node) {
let win = node.ownerDocument.defaultView;
executeSoon(() => EventUtils.synthesizeMouseAtCenter(node, {}, win));
}
/**
* Tests if clicking the tree items does the expected behavior
*/
function* testMouseInteraction(tree) {
info("Testing mouse interaction with the tree");
let event;
let pass = (e, d, a) => event.resolve([e, d, a]);
ok(!tree.selectedItem, "Nothing should be selected beforehand");
tree.once("select", pass);
let node = tree.root.children.firstChild.firstChild;
info("clicking on first top level item");
event = Promise.defer();
ok(!node.classList.contains("theme-selected"),
"Node should not have selected class before clicking");
click(node);
let [name, data, attachment] = yield event.promise;
ok(node.classList.contains("theme-selected"),
"Node has selected class after click");
is(data[0], "level1.2", "Correct tree path is emitted")
ok(attachment && attachment.foo, "Correct attachment is emitted")
is(attachment.foo, "bar", "Correct attachment value is emitted");
info("clicking second top level item with children to check if it expands");
let node2 = tree.root.children.firstChild.nextSibling.firstChild;
event = Promise.defer();
// node should not have selected class
ok(!node2.classList.contains("theme-selected"),
"New node should not have selected class before clicking");
ok(!node2.hasAttribute("expanded"), "New node is not expanded before clicking");
tree.once("select", pass);
click(node2);
[name, data, attachment] = yield event.promise;
ok(node2.classList.contains("theme-selected"),
"New node has selected class after clicking");
is(data[0], "level1", "Correct tree path is emitted for new node")
ok(!attachment, "null attachment should be emitted for new node")
ok(node2.hasAttribute("expanded"), "New node expanded after click");
ok(!node.classList.contains("theme-selected"),
"Old node should not have selected class after the click on new node");
// clicking again should just collapse
// this will not emit "select" event
event = Promise.defer();
node2.addEventListener("click", function onClick() {
node2.removeEventListener("click", onClick);
executeSoon(() => event.resolve(null));
});
click(node2);
yield event.promise;
ok(!node2.hasAttribute("expanded"), "New node collapsed after click again");
}