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

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: use mutationObserver to not mess with native dialog.open 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 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');
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
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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698