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 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) { | |
|
dpapad
2017/03/31 18:16:01
'overscroll' is used to indicate that blank space
scottchen
2017/03/31 20:20:20
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'); | |
|
dpapad
2017/03/31 18:16:01
Is this used anywhere?
scottchen
2017/03/31 20:20:20
I was using it to set height, but realized that ha
| |
| 57 var bodyContainer = dialog.$$('.body-container'); | |
| 58 assertTrue(!!bodyContainer); | |
| 59 | |
| 60 var observerCount = 0; | |
| 61 | |
| 62 // Needs to setup the observer before attaching, since InteractionObserver | |
| 63 // calls callback before MutationObserver does. | |
| 64 var observer = new MutationObserver(function() { | |
| 65 observerCount++; | |
| 66 console.log(observerCount); | |
|
dpapad
2017/03/31 18:16:01
Let's remove this.
scottchen
2017/03/31 20:20:20
Done.
| |
| 67 if (observerCount == 1) { // Triggered when scrolled to bottom. | |
| 68 assertFalse(bodyContainer.classList.contains('bottom-scrollable')); | |
| 69 bodyContainer.scrollTop = 0; | |
| 70 } else if (observerCount == 2) { // Triggered when scrolled back to top. | |
| 71 assertTrue(bodyContainer.classList.contains('bottom-scrollable')); | |
| 72 observer.disconnect(); | |
| 73 done(); | |
| 74 } | |
| 75 }); | |
| 76 observer.observe(bodyContainer, {attributes: true}); | |
| 77 | |
| 78 // Height is normally set via CSS, but mixin doesn't work with innerHTML. | |
| 79 bodyContainer.style.height = '1px'; | |
| 80 bodyContainer.scrollTop = 100; | |
| 81 dialog.showModal(); // Attach the dialog for the first time here. | |
| 82 }); | |
| 47 }); | 83 }); |
| OLD | NEW |