Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down.js

Issue 2911363002: DevTools: Split SoftDropdown out of ConsoleContextSelector (Closed)
Patch Set: fixes Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a7469704c25769b0c55a88e25223e97ca2a79d24
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down.js
@@ -0,0 +1,94 @@
+var items = [
+ {
+ title: "first",
+ index: 0
+ },
+ {
+ title: "second",
+ index: 1
+ },
+ {
+ title: "third",
+ index: 2
+ },
+ {
+ title: "fourth",
+ index: 3
+ },
+ {
+ title: "disabled 4.5",
+ disabled: true,
+ index: 4
+ },
+ {
+ title: "fifth",
+ index: 5
+ },
+ {
+ title: "sixth",
+ index: 6
+ },
+ {
+ title: "seventh",
+ index: 7
+ },
+ {
+ title: "eighth",
+ index: 8
+ }
+];
+
+class Delegate {
+ titleFor(item) {
+ return item.title;
+ }
+
+ createElementForItem(item) {
+ var element = createElement("div");
+ element.textContent = this.titleFor(item);
+ return element;
+ }
+
+ isItemSelectable(item) {
+ return !item.disabled;
+ }
+
+ itemSelected(item) {
+ if (item !== null)
+ TestRunner.addResult("Item selected: " + this.titleFor(item));
+ }
+
+ highlightedItemChanged(from, to, fromElement, toElement) {
+ if (to !== null)
+ TestRunner.addResult("Item highlighted: " + this.titleFor(to));
+ }
+};
+
+function pressKey(key) {
+ var element = document.deepActiveElement();
+ if (!element)
+ return;
+ TestRunner.addResult(key);
+ element.dispatchEvent(TestRunner.createKeyEvent(key));
+}
+var model = new UI.ListModel();
+var dropDown = new UI.SoftDropDown(model, new Delegate());
+for (var i = items.length - 1; i >= 0; i--)
+ model.insertWithComparator(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('f');
+pressKey('f');
+pressKey('t');
+TestRunner.completeTest();
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-drop-down-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698