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

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

Issue 2815623005: MD Settings: in cr_dialog, prevent intersectionObserver from firing early. (Closed)
Patch Set: reduce indentation 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
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
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');
158 assertFalse(dialog.open);
159 var bodyContainer = dialog.$$('.body-container');
160 assertTrue(!!bodyContainer);
161
162 // Waiting for 1ms because IntersectionObserver fires one message loop after
163 // dialog.attached.
164 setTimeout(function() {
165 assertFalse(bodyContainer.classList.contains('top-scrollable'));
166 assertFalse(bodyContainer.classList.contains('bottom-scrollable'));
167 done();
168 }, 1);
169 });
170
148 test('dialog body scrollable border when appropriate', function(done) { 171 test('dialog body scrollable border when appropriate', function(done) {
149 document.body.innerHTML = ` 172 document.body.innerHTML = `
150 <dialog is="cr-dialog" show-scroll-borders> 173 <dialog is="cr-dialog" show-scroll-borders>
151 <div class="title">title</div> 174 <div class="title">title</div>
152 <div class="body">body</div> 175 <div class="body">body</div>
153 </dialog>`; 176 </dialog>`;
154 177
155 var dialog = document.body.querySelector('dialog'); 178 var dialog = document.body.querySelector('dialog');
156 var bodyContainer = dialog.$$('.body-container'); 179 var bodyContainer = dialog.$$('.body-container');
157 assertTrue(!!bodyContainer); 180 assertTrue(!!bodyContainer);
(...skipping 29 matching lines...) Expand all
187 break; 210 break;
188 } 211 }
189 }); 212 });
190 observer.observe(bodyContainer, {attributes: true}); 213 observer.observe(bodyContainer, {attributes: true});
191 214
192 // Height is normally set via CSS, but mixin doesn't work with innerHTML. 215 // Height is normally set via CSS, but mixin doesn't work with innerHTML.
193 bodyContainer.style.height = '1px'; 216 bodyContainer.style.height = '1px';
194 bodyContainer.scrollTop = 100; 217 bodyContainer.scrollTop = 100;
195 }); 218 });
196 }); 219 });
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698