| Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c23ad052ba6b2ec45341dbe8349c53e024594845
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down.js
|
| @@ -0,0 +1,134 @@
|
| +var items = [
|
| + {
|
| + title: "first",
|
| + depth: 0,
|
| + index: 0
|
| + },
|
| + {
|
| + title: "second",
|
| + depth: 0,
|
| + index: 1
|
| + },
|
| + {
|
| + title: "third",
|
| + depth: 0,
|
| + index: 2
|
| + },
|
| + {
|
| + title: "fourth",
|
| + depth: 0,
|
| + index: 3
|
| + },
|
| + {
|
| + title: "disabled 4.5",
|
| + disabled: true,
|
| + depth: 0,
|
| + index: 4
|
| + },
|
| + {
|
| + title: "fifth",
|
| + depth: 0,
|
| + index: 5
|
| + },
|
| + {
|
| + title: "sixth",
|
| + depth: 0,
|
| + index: 6
|
| + },
|
| + {
|
| + title: "seventh",
|
| + depth: 0,
|
| + index: 7
|
| + },
|
| + {
|
| + title: "seventh-sub-item",
|
| + depth: 1,
|
| + index: 8
|
| + },
|
| + {
|
| + title: "seventh-sub-sub-item",
|
| + depth: 2,
|
| + index: 9
|
| + },
|
| + {
|
| + title: "eighth",
|
| + depth: 0,
|
| + index: 10
|
| + }
|
| +];
|
| +
|
| +class Delegate {
|
| + titleFor(item) {
|
| + return item.title;
|
| + }
|
| +
|
| + depthFor(item) {
|
| + return item.depth;
|
| + }
|
| +
|
| + elementForItem(item) {
|
| + var div = createElement("div");
|
| + div.textContent = this.titleFor(item);
|
| + return div;
|
| + }
|
| +
|
| + /**
|
| + * @param {T} item
|
| + * @return {boolean}
|
| + */
|
| + isItemSelectable(item) {
|
| + return !item.disabled;
|
| + }
|
| +
|
| + /**
|
| + * @param {?T} item
|
| + */
|
| + itemSelected(item) {
|
| + if (item !== null)
|
| + TestRunner.addResult("Item selected: " + this.titleFor(item));
|
| + }
|
| +
|
| + /**
|
| + * @param {?T} item
|
| + */
|
| + itemHighlighted(item) {
|
| + if (item !== null)
|
| + TestRunner.addResult("Item highlighted: " + this.titleFor(item));
|
| + }
|
| +};
|
| +
|
| +function pressKey(key) {
|
| + var element = document.deepActiveElement();
|
| + if (!element)
|
| + return;
|
| + TestRunner.addResult(key);
|
| + element.dispatchEvent(TestRunner.createKeyEvent(key));
|
| +}
|
| +
|
| +var dropDown = new UI.SoftDropDown(new Delegate());
|
| +for (var i = items.length - 1; i >= 0; i--) {
|
| + dropDown.insertItemWithComparator(items[i], (a, b) => a.index - b.index);
|
| +}
|
| +UI.inspectorView.element.appendChild(dropDown.element);
|
| +dropDown.selectItem(items[5]);
|
| +TestRunner.addResult("Showing drop down");
|
| +dropDown.element.dispatchEvent(new Event("mousedown"));
|
| +pressKey('ArrowDown');
|
| +pressKey('ArrowDown');
|
| +pressKey('ArrowDown');
|
| +pressKey('ArrowUp');
|
| +pressKey('ArrowUp');
|
| +pressKey('ArrowUp');
|
| +pressKey('ArrowDown');
|
| +pressKey('ArrowDown');
|
| +pressKey('ArrowRight');
|
| +pressKey('ArrowRight');
|
| +pressKey('ArrowRight');
|
| +pressKey('ArrowLeft');
|
| +pressKey('ArrowLeft');
|
| +pressKey('ArrowLeft');
|
| +pressKey('ArrowLeft');
|
| +pressKey('f');
|
| +pressKey('f');
|
| +pressKey('t');
|
| +TestRunner.completeTest();
|
|
|