Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/test/data/webui/cr_elements/cr_dialog_test.js

Issue 2702523005: MD Settings: long dialog body should have overscroll line. (Closed)
Patch Set: remove unused variable Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 scrollable border 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 bodyContainer = dialog.$$('.body-container');
57 assertTrue(!!bodyContainer);
58
59 var observerCount = 0;
60
61 // Needs to setup the observer before attaching, since InteractionObserver
62 // calls callback before MutationObserver does.
63 var observer = new MutationObserver(function() {
64 observerCount++;
65 if (observerCount == 1) { // Triggered when scrolled to bottom.
66 assertFalse(bodyContainer.classList.contains('bottom-scrollable'));
67 bodyContainer.scrollTop = 0;
68 } else if (observerCount == 2) { // Triggered when scrolled back to top.
69 assertTrue(bodyContainer.classList.contains('bottom-scrollable'));
70 observer.disconnect();
71 done();
72 }
73 });
74 observer.observe(bodyContainer, {attributes: true});
75
76 // Height is normally set via CSS, but mixin doesn't work with innerHTML.
77 bodyContainer.style.height = '1px';
78 bodyContainer.scrollTop = 100;
79 dialog.showModal(); // Attach the dialog for the first time here.
80 });
47 }); 81 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698