update components
This commit is contained in:
parent
8d9ac6ef88
commit
2a4b879c21
9 changed files with 92 additions and 27 deletions
|
@ -70,7 +70,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
test('first item gets focus when menu is focused', function(done) {
|
||||
var menu = fixture('basic');
|
||||
menu.focus();
|
||||
MockInteractions.focus(menu);
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, menu.firstElementChild, 'document.activeElement is first item')
|
||||
done();
|
||||
|
@ -81,7 +81,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
test('selected item gets focus when menu is focused', function(done) {
|
||||
var menu = fixture('basic');
|
||||
menu.selected = 1;
|
||||
menu.focus();
|
||||
MockInteractions.focus(menu);
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, menu.selectedItem, 'document.activeElement is selected item');
|
||||
done();
|
||||
|
|
|
@ -19,6 +19,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
|
||||
<link rel="import" href="test-menubar.html">
|
||||
|
||||
</head>
|
||||
|
@ -44,6 +45,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="rtl">
|
||||
<template>
|
||||
<div dir="rtl">
|
||||
<test-menubar>
|
||||
<div>item 1</div>
|
||||
<div>item 2</div>
|
||||
<div>item 3</div>
|
||||
</test-menubar>
|
||||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('menubar a11y tests', function() {
|
||||
|
@ -55,9 +68,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
test('first item gets focus when menubar is focused', function(done) {
|
||||
var menubar = fixture('basic');
|
||||
menubar.focus();
|
||||
MockInteractions.focus(menubar);
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, menubar.firstElementChild, 'document.activeElement is first item')
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.firstElementChild, 'document.activeElement is first item')
|
||||
done();
|
||||
// wait for async in _onFocus
|
||||
}, 200);
|
||||
|
@ -66,9 +79,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
test('selected item gets focus when menubar is focused', function(done) {
|
||||
var menubar = fixture('basic');
|
||||
menubar.selected = 1;
|
||||
menubar.focus();
|
||||
MockInteractions.focus(menubar);
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, menubar.selectedItem, 'document.activeElement is selected item');
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.selectedItem, 'document.activeElement is selected item');
|
||||
done();
|
||||
// wait for async in _onFocus
|
||||
}, 200);
|
||||
|
@ -79,7 +92,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
menubar.selected = 0;
|
||||
menubar.items[1].click();
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, menubar.items[1], 'document.activeElement is last activated item');
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.items[1], 'document.activeElement is last activated item');
|
||||
done();
|
||||
// wait for async in _onFocus
|
||||
}, 200);
|
||||
|
@ -90,12 +103,49 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
menubar.selected = 0;
|
||||
menubar.items[0].click();
|
||||
setTimeout(function() {
|
||||
assert.equal(document.activeElement, menubar.items[0], 'document.activeElement is last activated item');
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.items[0], 'document.activeElement is last activated item');
|
||||
done();
|
||||
// wait for async in _onFocus
|
||||
}, 200);
|
||||
});
|
||||
|
||||
suite('left / right keys are reversed when the menubar has RTL directionality', function() {
|
||||
var LEFT = 37;
|
||||
var RIGHT = 39;
|
||||
|
||||
test('left key moves to the next item', function() {
|
||||
var rtlContainer = fixture('rtl');
|
||||
var menubar = rtlContainer.querySelector('test-menubar');
|
||||
menubar.selected = 0;
|
||||
menubar.items[1].click();
|
||||
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.items[1]);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(menubar, LEFT);
|
||||
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.items[2],
|
||||
'`document.activeElement` should be the next item.');
|
||||
assert.equal(menubar.selected, 1,
|
||||
'`menubar.selected` should not change.');
|
||||
});
|
||||
|
||||
test('right key moves to the previous item', function() {
|
||||
var rtlContainer = fixture('rtl');
|
||||
var menubar = rtlContainer.querySelector('test-menubar');
|
||||
menubar.selected = 0;
|
||||
menubar.items[1].click();
|
||||
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.items[1]);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(menubar, RIGHT);
|
||||
|
||||
assert.equal(Polymer.dom(document).activeElement, menubar.items[0],
|
||||
'`document.activeElement` should be the previous item');
|
||||
assert.equal(menubar.selected, 1,
|
||||
'`menubar.selected` should not change.');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue