| Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/tabbed-pane.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/tabbed-pane.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/tabbed-pane.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9782aba45fa6272cd15c7a23937730d7de4fd444
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/tabbed-pane.js
|
| @@ -0,0 +1,62 @@
|
| +TestRunner.addResult("This tests if the TabbedPane is keyboard navigable.");
|
| +
|
| +class FocusableWidget extends UI.Widget {
|
| + constructor(name) {
|
| + super();
|
| + this.element.tabIndex = -1;
|
| + this.element.textContent = name;
|
| + this.setDefaultFocusedElement(this.element);
|
| + }
|
| +}
|
| +
|
| +var tabbedPane = new UI.TabbedPane();
|
| +tabbedPane.show(UI.inspectorView.element);
|
| +TestRunner.addSniffer(tabbedPane, '_innerUpdateTabElements').then(tabsAdded);
|
| +for (var i = 0; i < 10; i++)
|
| + tabbedPane.appendTab(i.toString(), 'Tab ' + i, new FocusableWidget('Widget ' + i));
|
| +
|
| +function tabsAdded() {
|
| + tabbedPane._currentTab.tabElement.focus();
|
| + dumpFocus();
|
| + TestRunner.addResult('Moving right and wrapping around');
|
| + for (var i = 0; i < 20; i++)
|
| + right();
|
| + TestRunner.addResult('Moving left and focusing widgets')
|
| + for (var i = 0; i < 10; i++) {
|
| + left();
|
| + enter();
|
| + tabbedPane._currentTab.tabElement.focus();
|
| + }
|
| + TestRunner.completeTest();
|
| +}
|
| +
|
| +function right() {
|
| + var element = document.deepActiveElement();
|
| + if (element)
|
| + element.dispatchEvent(TestRunner.createKeyEvent('ArrowRight'));
|
| + dumpFocus();
|
| +}
|
| +
|
| +function left() {
|
| + var element = document.deepActiveElement();
|
| + if (element)
|
| + element.dispatchEvent(TestRunner.createKeyEvent('ArrowLeft'));
|
| + dumpFocus();
|
| +}
|
| +
|
| +function enter() {
|
| + var element = document.deepActiveElement();
|
| + if (element)
|
| + element.dispatchEvent(TestRunner.createKeyEvent('Enter'));
|
| + dumpFocus();
|
| +}
|
| +
|
| +
|
| +function dumpFocus() {
|
| + var element = document.deepActiveElement();
|
| + if (!element) {
|
| + TestRunner.addResult("null");
|
| + return;
|
| + }
|
| + TestRunner.addResult(element.textContent);
|
| +}
|
|
|