Chromium Code Reviews| 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 function pressEnter(element) { | 6 function pressEnter(element) { |
| 7 MockInteractions.keyEventOn(element, 'keypress', 13, undefined, 'Enter'); | 7 MockInteractions.keyEventOn(element, 'keypress', 13, undefined, 'Enter'); |
| 8 } | 8 } |
| 9 | 9 |
| 10 setup(function() { | 10 setup(function() { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 | 138 |
| 139 assertNotEquals(dialog, document.activeElement); | 139 assertNotEquals(dialog, document.activeElement); |
| 140 assertNotEquals(button, document.activeElement); | 140 assertNotEquals(button, document.activeElement); |
| 141 | 141 |
| 142 dialog.showModal(); | 142 dialog.showModal(); |
| 143 | 143 |
| 144 expectNotEquals(dialog, document.activeElement); | 144 expectNotEquals(dialog, document.activeElement); |
| 145 expectEquals(button, document.activeElement); | 145 expectEquals(button, document.activeElement); |
| 146 }); | 146 }); |
| 147 | 147 |
| 148 // Ensuring that intersectionObserver does not fire any callbacks before the | |
| 149 // dialog has been opened. | |
| 150 test('body scrollable border not added before modal shown', function(done) { | |
| 151 document.body.innerHTML = ` | |
| 152 <dialog is="cr-dialog" show-scroll-borders> | |
| 153 <div class="title">title</div> | |
| 154 <div class="body">body</div> | |
| 155 </dialog>`; | |
| 156 | |
| 157 var dialog = document.body.querySelector('dialog'); | |
|
dpapad
2017/04/13 20:31:39
Just to make it explicit, let's also add
assertFa
scottchen
2017/04/13 21:46:04
Done.
| |
| 158 var bodyContainer = dialog.$$('.body-container'); | |
| 159 assertTrue(!!bodyContainer); | |
| 160 | |
| 161 // Waiting for 1ms because IntersectionObserver fires one message loop after | |
| 162 // dialog.attached. | |
| 163 setTimeout(function() { | |
| 164 assertFalse(bodyContainer.classList.contains('top-scrollable')); | |
| 165 assertFalse(bodyContainer.classList.contains('bottom-scrollable')); | |
| 166 done(); | |
| 167 }, 1); | |
| 168 }); | |
| 169 | |
| 148 test('dialog body scrollable border when appropriate', function(done) { | 170 test('dialog body scrollable border when appropriate', function(done) { |
| 149 document.body.innerHTML = ` | 171 document.body.innerHTML = ` |
| 150 <dialog is="cr-dialog" show-scroll-borders> | 172 <dialog is="cr-dialog" show-scroll-borders> |
| 151 <div class="title">title</div> | 173 <div class="title">title</div> |
| 152 <div class="body">body</div> | 174 <div class="body">body</div> |
| 153 </dialog>`; | 175 </dialog>`; |
| 154 | 176 |
| 155 var dialog = document.body.querySelector('dialog'); | 177 var dialog = document.body.querySelector('dialog'); |
| 156 var bodyContainer = dialog.$$('.body-container'); | 178 var bodyContainer = dialog.$$('.body-container'); |
| 157 assertTrue(!!bodyContainer); | 179 assertTrue(!!bodyContainer); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 187 break; | 209 break; |
| 188 } | 210 } |
| 189 }); | 211 }); |
| 190 observer.observe(bodyContainer, {attributes: true}); | 212 observer.observe(bodyContainer, {attributes: true}); |
| 191 | 213 |
| 192 // Height is normally set via CSS, but mixin doesn't work with innerHTML. | 214 // Height is normally set via CSS, but mixin doesn't work with innerHTML. |
| 193 bodyContainer.style.height = '1px'; | 215 bodyContainer.style.height = '1px'; |
| 194 bodyContainer.scrollTop = 100; | 216 bodyContainer.scrollTop = 100; |
| 195 }); | 217 }); |
| 196 }); | 218 }); |
| OLD | NEW |