| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <!-- | 2 <!-- |
| 3 @license | 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 8 Code distributed by Google as part of the polymer project is also | 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> | 10 --> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 <test-overlay with-backdrop class="overlay-3"> | 79 <test-overlay with-backdrop class="overlay-3"> |
| 80 Overlay 3 with backdrop | 80 Overlay 3 with backdrop |
| 81 </test-overlay> | 81 </test-overlay> |
| 82 </template> | 82 </template> |
| 83 </test-fixture> | 83 </test-fixture> |
| 84 | 84 |
| 85 <script> | 85 <script> |
| 86 | 86 |
| 87 function runAfterOpen(overlay, cb) { | 87 function runAfterOpen(overlay, cb) { |
| 88 overlay.addEventListener('iron-overlay-opened', function() { | 88 overlay.addEventListener('iron-overlay-opened', function() { |
| 89 cb(); | 89 Polymer.Base.async(cb, 1); |
| 90 }); | 90 }); |
| 91 overlay.open(); | 91 overlay.open(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 suite('basic overlay tests', function() { | 94 suite('basic overlay tests', function() { |
| 95 var overlay; | 95 var overlay; |
| 96 | 96 |
| 97 setup(function() { | 97 setup(function() { |
| 98 overlay = fixture('basic'); | 98 overlay = fixture('basic'); |
| 99 }); | 99 }); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 test('node with autofocus is focused', function(done) { | 174 test('node with autofocus is focused', function(done) { |
| 175 overlay = fixture('autofocus'); | 175 overlay = fixture('autofocus'); |
| 176 runAfterOpen(overlay, function() { | 176 runAfterOpen(overlay, function() { |
| 177 assert.equal(Polymer.dom(overlay).querySelector('[autofocus]'), docu
ment.activeElement, '<button autofocus> is focused'); | 177 assert.equal(Polymer.dom(overlay).querySelector('[autofocus]'), docu
ment.activeElement, '<button autofocus> is focused'); |
| 178 done(); | 178 done(); |
| 179 }); | 179 }); |
| 180 }); | 180 }); |
| 181 | 181 |
| 182 test('cancel an overlay by clicking outside', function(done) { | 182 test('cancel an overlay by clicking outside', function(done) { |
| 183 runAfterOpen(overlay, function() { | 183 runAfterOpen(overlay, function() { |
| 184 overlay.addEventListener('iron-overlay-canceled', function(event) { |
| 185 done(); |
| 186 }); |
| 187 Polymer.Base.fire.call(document, 'click'); |
| 188 }); |
| 189 }); |
| 190 |
| 191 test('close an overlay by clicking outside', function(done) { |
| 192 runAfterOpen(overlay, function() { |
| 184 overlay.addEventListener('iron-overlay-closed', function(event) { | 193 overlay.addEventListener('iron-overlay-closed', function(event) { |
| 185 assert.isTrue(event.detail.canceled, 'overlay is canceled'); | 194 assert.isTrue(event.detail.canceled, 'overlay is canceled'); |
| 186 done(); | 195 done(); |
| 187 }); | 196 }); |
| 188 Polymer.Base.fire.call(document, 'click'); | 197 Polymer.Base.fire.call(document, 'click'); |
| 189 }); | 198 }); |
| 190 }); | 199 }); |
| 191 | 200 |
| 201 test('cancel event can be prevented', function(done) { |
| 202 runAfterOpen(overlay, function() { |
| 203 overlay.addEventListener('iron-overlay-canceled', function(event) { |
| 204 event.preventDefault(); |
| 205 }); |
| 206 var closedListener = function(event) { |
| 207 throw new Error('iron-overlay-closed should not fire'); |
| 208 }; |
| 209 overlay.addEventListener('iron-overlay-closed', closedListener); |
| 210 Polymer.Base.fire.call(document, 'click'); |
| 211 setTimeout(function() { |
| 212 overlay.removeEventListener('iron-overlay-closed', closedListener)
; |
| 213 done(); |
| 214 }, 10); |
| 215 }); |
| 216 }); |
| 217 |
| 192 test('cancel an overlay with esc key', function(done) { | 218 test('cancel an overlay with esc key', function(done) { |
| 193 runAfterOpen(overlay, function() { | 219 runAfterOpen(overlay, function() { |
| 220 overlay.addEventListener('iron-overlay-canceled', function(event) { |
| 221 done(); |
| 222 }); |
| 223 fireEvent('keydown', { |
| 224 keyCode: 27 |
| 225 }, document); |
| 226 }); |
| 227 }); |
| 228 |
| 229 test('close an overlay with esc key', function(done) { |
| 230 runAfterOpen(overlay, function() { |
| 194 overlay.addEventListener('iron-overlay-closed', function(event) { | 231 overlay.addEventListener('iron-overlay-closed', function(event) { |
| 195 assert.isTrue(event.detail.canceled, 'overlay is canceled'); | 232 assert.isTrue(event.detail.canceled, 'overlay is canceled'); |
| 196 done(); | 233 done(); |
| 197 }); | 234 }); |
| 198 fireEvent('keydown', { | 235 fireEvent('keydown', { |
| 199 keyCode: 27 | 236 keyCode: 27 |
| 200 }, document); | 237 }, document); |
| 201 }); | 238 }); |
| 202 }); | 239 }); |
| 203 | 240 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 overlay.close(); | 360 overlay.close(); |
| 324 assert.equal(overlay.getAttribute('aria-hidden'), 'true', 'overlay has
aria-hidden="true"'); | 361 assert.equal(overlay.getAttribute('aria-hidden'), 'true', 'overlay has
aria-hidden="true"'); |
| 325 }); | 362 }); |
| 326 | 363 |
| 327 }) | 364 }) |
| 328 | 365 |
| 329 </script> | 366 </script> |
| 330 | 367 |
| 331 </body> | 368 </body> |
| 332 </html> | 369 </html> |
| OLD | NEW |