1<!doctype html> 2<!-- 3@license 4Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 8Code distributed by Google as part of the polymer project is also 9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 10--> 11<html> 12 13<head> 14 15 <title>paper-dialog tests</title> 16 17 <meta charset="utf-8"> 18 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 19 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> 20 21 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> 22 <script src="../../web-component-tester/browser.js"></script> 23 <link rel="import" href="../paper-dialog.html"> 24</head> 25 26<body> 27 28 <test-fixture id="basic"> 29 <template> 30 <paper-dialog> 31 <p>Dialog</p> 32 </paper-dialog> 33 </template> 34 </test-fixture> 35 36 <test-fixture id="modal"> 37 <template> 38 <paper-dialog modal> 39 <p>Dialog</p> 40 </paper-dialog> 41 </template> 42 </test-fixture> 43 44 <test-fixture id="opened-modals"> 45 <template> 46 <paper-dialog modal opened> 47 <p>Dialog 1</p> 48 <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> 49 </paper-dialog> 50 <paper-dialog modal opened> 51 <p>Dialog 2</p> 52 </paper-dialog> 53 </template> 54 </test-fixture> 55 56 <script> 57 suite('modal', function() { 58 59 test('backdrop element remains opened when closing top modal, closes when all modals are closed', function(done) { 60 var modals = fixture('opened-modals'); 61 modals[1].addEventListener('iron-overlay-opened', function() { 62 assert.isTrue(modals[1].backdropElement.opened, 'backdrop is open'); 63 modals[1].close(); 64 }); 65 modals[1].addEventListener('iron-overlay-closed', function() { 66 assert.isTrue(modals[1].backdropElement.opened, 'backdrop is still open'); 67 modals[0].close(); 68 }); 69 modals[0].addEventListener('iron-overlay-closed', function() { 70 assert.isFalse(modals[0].backdropElement.opened, 'backdrop is closed'); 71 done(); 72 }); 73 }); 74 75 }); 76 77 suite('a11y', function() { 78 a11ySuite('basic', []); 79 80 a11ySuite('modal', []); 81 82 test('dialog has role="dialog"', function() { 83 var dialog = fixture('basic'); 84 assert.equal(dialog.getAttribute('role'), 'dialog', 'has role="dialog"'); 85 }); 86 87 }); 88 </script> 89 90</body> 91 92</html> 93