OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 <html> |
| 11 <head> |
| 12 <title>focused-state</title> |
| 13 |
| 14 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 15 <script src="../../web-component-tester/browser.js"></script> |
| 16 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 17 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 18 |
| 19 <link rel="import" href="../../polymer/polymer.html"> |
| 20 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 21 <link rel="import" href="test-elements.html"> |
| 22 </head> |
| 23 <body> |
| 24 |
| 25 <test-fixture id="TrivialFocusedState"> |
| 26 <template> |
| 27 <test-control tabindex="-1"></test-control> |
| 28 </template> |
| 29 </test-fixture> |
| 30 |
| 31 <script> |
| 32 suite('focused-state', function() { |
| 33 var focusTarget; |
| 34 |
| 35 setup(function() { |
| 36 focusTarget = fixture('TrivialFocusedState'); |
| 37 }); |
| 38 |
| 39 suite('when is focused', function() { |
| 40 test('receives a focused attribute', function() { |
| 41 expect(focusTarget.hasAttribute('focused')).to.be.eql(false); |
| 42 MockInteractions.focus(focusTarget); |
| 43 expect(focusTarget.hasAttribute('focused')).to.be.eql(true); |
| 44 }); |
| 45 |
| 46 test('focused property is true', function() { |
| 47 expect(focusTarget.focused).to.not.be.eql(true); |
| 48 MockInteractions.focus(focusTarget); |
| 49 expect(focusTarget.focused).to.be.eql(true); |
| 50 }); |
| 51 }); |
| 52 |
| 53 suite('when is blurred', function() { |
| 54 test('loses the focused attribute', function() { |
| 55 MockInteractions.focus(focusTarget); |
| 56 expect(focusTarget.hasAttribute('focused')).to.be.eql(true); |
| 57 MockInteractions.blur(focusTarget); |
| 58 expect(focusTarget.hasAttribute('focused')).to.be.eql(false); |
| 59 }); |
| 60 |
| 61 test('focused property is false', function() { |
| 62 MockInteractions.focus(focusTarget); |
| 63 expect(focusTarget.focused).to.be.eql(true); |
| 64 MockInteractions.blur(focusTarget); |
| 65 expect(focusTarget.focused).to.be.eql(false); |
| 66 }); |
| 67 }); |
| 68 |
| 69 suite('when the focused state is disabled', function() { |
| 70 setup(function() { |
| 71 focusTarget.disabled = true; |
| 72 }); |
| 73 |
| 74 test('will not be focusable', function() { |
| 75 expect(focusTarget.getAttribute('tabindex')).to.be.eql('-1'); |
| 76 }); |
| 77 }); |
| 78 }); |
| 79 </script> |
| 80 |
| 81 </body> |
| 82 </html> |
OLD | NEW |