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

Side by Side Diff: polymer_1.0.4/bower_components/iron-behaviors/test/focused-state.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 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 unified diff | Download patch
OLDNEW
(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 <test-fixture id="NestedFocusedState">
32 <template>
33 <nested-focusable></nested-focusable>
34 </template>
35 </test-fixture>
36
37 <script>
38 suite('focused-state', function() {
39 var focusTarget;
40
41 setup(function() {
42 focusTarget = fixture('TrivialFocusedState');
43 });
44
45 suite('when is focused', function() {
46 test('receives a focused attribute', function() {
47 expect(focusTarget.hasAttribute('focused')).to.be.eql(false);
48 MockInteractions.focus(focusTarget);
49 expect(focusTarget.hasAttribute('focused')).to.be.eql(true);
50 });
51
52 test('focused property is true', function() {
53 expect(focusTarget.focused).to.not.be.eql(true);
54 MockInteractions.focus(focusTarget);
55 expect(focusTarget.focused).to.be.eql(true);
56 });
57 });
58
59 suite('when is blurred', function() {
60 test('loses the focused attribute', function() {
61 MockInteractions.focus(focusTarget);
62 expect(focusTarget.hasAttribute('focused')).to.be.eql(true);
63 MockInteractions.blur(focusTarget);
64 expect(focusTarget.hasAttribute('focused')).to.be.eql(false);
65 });
66
67 test('focused property is false', function() {
68 MockInteractions.focus(focusTarget);
69 expect(focusTarget.focused).to.be.eql(true);
70 MockInteractions.blur(focusTarget);
71 expect(focusTarget.focused).to.be.eql(false);
72 });
73 });
74
75 suite('when the focused state is disabled', function() {
76 setup(function() {
77 focusTarget.disabled = true;
78 });
79
80 test('will not be focusable', function() {
81 expect(focusTarget.getAttribute('tabindex')).to.be.eql('-1');
82 });
83 });
84 });
85
86 suite('nested focusable', function() {
87 var focusable;
88
89 setup(function() {
90 focusable = fixture('NestedFocusedState');
91 });
92
93 test('focus/blur events fired on host element', function(done) {
94 var nFocusEvents = 0;
95 var nBlurEvents = 0;
96 focusable.addEventListener('focus', function() {
97 nFocusEvents += 1;
98 // setTimeout to wait for potentially more, erroneous events
99 setTimeout(function() {
100 assert.equal(nFocusEvents, 1, 'one focus event fired');
101 MockInteractions.blur(focusable.$.input);
102 });
103 });
104 focusable.addEventListener('blur', function() {
105 nBlurEvents += 1;
106 // setTimeout to wait for potentially more, erroneous events
107 setTimeout(function() {
108 assert.equal(nBlurEvents, 1, 'one blur event fired');
109 done();
110 });
111 });
112 MockInteractions.focus(focusable.$.input);
113 });
114
115 });
116
117 </script>
118
119 </body>
120 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698