OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 suite('cr-dialog', function() { | 5 suite('cr-dialog', function() { |
6 setup(function() { | 6 setup(function() { |
7 PolymerTest.clearBody(); | 7 PolymerTest.clearBody(); |
8 }); | 8 }); |
9 | 9 |
10 test('focuses title on show', function() { | 10 test('focuses title on show', function() { |
(...skipping 26 matching lines...) Expand all Loading... | |
37 var button = document.body.querySelector('button'); | 37 var button = document.body.querySelector('button'); |
38 | 38 |
39 assertNotEquals(dialog, document.activeElement); | 39 assertNotEquals(dialog, document.activeElement); |
40 assertNotEquals(button, document.activeElement); | 40 assertNotEquals(button, document.activeElement); |
41 | 41 |
42 dialog.showModal(); | 42 dialog.showModal(); |
43 | 43 |
44 expectNotEquals(dialog, document.activeElement); | 44 expectNotEquals(dialog, document.activeElement); |
45 expectEquals(button, document.activeElement); | 45 expectEquals(button, document.activeElement); |
46 }); | 46 }); |
47 | |
48 test('dialog body indicates over-scroll when appropriate', function(done) { | |
49 document.body.innerHTML = ` | |
50 <dialog is="cr-dialog" show-scroll-borders> | |
51 <div class="title">title</div> | |
52 <div class="body">body</div> | |
53 </dialog>`; | |
54 | |
55 var dialog = document.body.querySelector('dialog'); | |
56 var innerBody = document.body.querySelector('.body'); | |
57 var bodyContainer = dialog.$$('.body-container'); | |
58 assertTrue(!!bodyContainer); | |
59 | |
60 // Height is normally set via CSS, but mixin doesn't work with innerHTML. | |
61 bodyContainer.style.height = '1px'; | |
62 innerBody.style.height = '100px'; | |
63 dialog.showModal(); | |
64 | |
65 return PolymerTest.flushTasks().then(function() { | |
dpapad
2017/03/31 01:55:26
Optional nit: Perhaps this test is more readable i
scottchen
2017/03/31 18:10:56
Done.
| |
66 assertTrue(bodyContainer.classList.contains('bottom-scrollable')); | |
67 | |
68 var observer = new MutationObserver(function() { | |
69 assertFalse(bodyContainer.classList.contains('bottom-scrollable')); | |
70 observer.disconnect(); | |
71 done(); | |
72 }); | |
73 observer.observe(bodyContainer, {attributes: true}); | |
74 | |
75 bodyContainer.scrollTop = 100; | |
76 }); | |
77 }); | |
47 }); | 78 }); |
OLD | NEW |