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

Side by Side Diff: chrome/test/data/webui/settings/privacy_page_test.js

Issue 2180823004: Migrate <cr-dialog> from PaperDialogBehavior to native <dialog>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Populating |returnValue|. Created 4 years, 4 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 cr.define('settings_privacy_page', function() { 5 cr.define('settings_privacy_page', function() {
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @extends {TestBrowserProxy} 8 * @extends {TestBrowserProxy}
9 * @implements {settings.PrivacyPageBrowserProxy} 9 * @implements {settings.PrivacyPageBrowserProxy}
10 */ 10 */
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; 106 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy;
107 PolymerTest.clearBody(); 107 PolymerTest.clearBody();
108 element = document.createElement('settings-clear-browsing-data-dialog'); 108 element = document.createElement('settings-clear-browsing-data-dialog');
109 document.body.appendChild(element); 109 document.body.appendChild(element);
110 return testBrowserProxy.whenCalled('initialize'); 110 return testBrowserProxy.whenCalled('initialize');
111 }); 111 });
112 112
113 teardown(function() { element.remove(); }); 113 teardown(function() { element.remove(); });
114 114
115 test('ClearBrowsingDataTap', function() { 115 test('ClearBrowsingDataTap', function() {
116 assertTrue(element.$.dialog.opened); 116 assertTrue(element.$.dialog.open);
117 117
118 var cancelButton = element.$$('.cancel-button'); 118 var cancelButton = element.$$('.cancel-button');
119 assertTrue(!!cancelButton); 119 assertTrue(!!cancelButton);
120 var actionButton = element.$$('.action-button'); 120 var actionButton = element.$$('.action-button');
121 assertTrue(!!actionButton); 121 assertTrue(!!actionButton);
122 var spinner = element.$$('paper-spinner'); 122 var spinner = element.$$('paper-spinner');
123 assertTrue(!!spinner); 123 assertTrue(!!spinner);
124 124
125 assertFalse(cancelButton.disabled); 125 assertFalse(cancelButton.disabled);
126 assertFalse(actionButton.disabled); 126 assertFalse(actionButton.disabled);
127 assertFalse(spinner.active); 127 assertFalse(spinner.active);
128 128
129 var promiseResolver = new PromiseResolver(); 129 var promiseResolver = new PromiseResolver();
130 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise); 130 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise);
131 MockInteractions.tap(actionButton); 131 MockInteractions.tap(actionButton);
132 132
133 return testBrowserProxy.whenCalled('clearBrowsingData').then( 133 return testBrowserProxy.whenCalled('clearBrowsingData').then(
134 function() { 134 function() {
135 assertTrue(element.$.dialog.opened); 135 assertTrue(element.$.dialog.open);
136 assertTrue(cancelButton.disabled); 136 assertTrue(cancelButton.disabled);
137 assertTrue(actionButton.disabled); 137 assertTrue(actionButton.disabled);
138 assertTrue(spinner.active); 138 assertTrue(spinner.active);
139 139
140 // Simulate signal from browser indicating that clearing has 140 // Simulate signal from browser indicating that clearing has
141 // completed. 141 // completed.
142 cr.webUIListenerCallback('browsing-data-removing', false); 142 cr.webUIListenerCallback('browsing-data-removing', false);
143 promiseResolver.resolve(); 143 promiseResolver.resolve();
144 // Yields to the message loop to allow the callback chain of the 144 // Yields to the message loop to allow the callback chain of the
145 // Promise that was just resolved to execute before the 145 // Promise that was just resolved to execute before the
146 // assertions. 146 // assertions.
147 }).then(function() { 147 }).then(function() {
148 assertFalse(element.$.dialog.opened); 148 assertFalse(element.$.dialog.open);
149 assertFalse(cancelButton.disabled); 149 assertFalse(cancelButton.disabled);
150 assertFalse(actionButton.disabled); 150 assertFalse(actionButton.disabled);
151 assertFalse(spinner.active); 151 assertFalse(spinner.active);
152 assertFalse(!!element.$$('#notice')); 152 assertFalse(!!element.$$('#notice'));
153 }); 153 });
154 }); 154 });
155 155
156 test('showHistoryDeletionDialog', function() { 156 test('showHistoryDeletionDialog', function() {
157 assertTrue(element.$.dialog.opened); 157 assertTrue(element.$.dialog.open);
158 var actionButton = element.$$('.action-button'); 158 var actionButton = element.$$('.action-button');
159 assertTrue(!!actionButton); 159 assertTrue(!!actionButton);
160 160
161 var promiseResolver = new PromiseResolver(); 161 var promiseResolver = new PromiseResolver();
162 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise); 162 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise);
163 MockInteractions.tap(actionButton); 163 MockInteractions.tap(actionButton);
164 164
165 return testBrowserProxy.whenCalled('clearBrowsingData').then( 165 return testBrowserProxy.whenCalled('clearBrowsingData').then(
166 function() { 166 function() {
167 // Passing showNotice = true should trigger the notice about other 167 // Passing showNotice = true should trigger the notice about other
168 // forms of browsing history to open, and the dialog to stay open. 168 // forms of browsing history to open, and the dialog to stay open.
169 promiseResolver.resolve(true /* showNotice */); 169 promiseResolver.resolve(true /* showNotice */);
170 170
171 // Yields to the message loop to allow the callback chain of the 171 // Yields to the message loop to allow the callback chain of the
172 // Promise that was just resolved to execute before the 172 // Promise that was just resolved to execute before the
173 // assertions. 173 // assertions.
174 }).then(function() { 174 }).then(function() {
175 Polymer.dom.flush(); 175 Polymer.dom.flush();
176 var notice = element.$$('#notice'); 176 var notice = element.$$('#notice');
177 assertTrue(!!notice); 177 assertTrue(!!notice);
178 var noticeActionButton = notice.$$('.action-button'); 178 var noticeActionButton = notice.$$('.action-button');
179 assertTrue(!!noticeActionButton); 179 assertTrue(!!noticeActionButton);
180 180
181 assertTrue(element.$.dialog.opened); 181 assertTrue(element.$.dialog.open);
182 assertTrue(notice.$.dialog.opened); 182 assertTrue(notice.$.dialog.open);
183 183
184 MockInteractions.tap(noticeActionButton); 184 MockInteractions.tap(noticeActionButton);
185 185
186 // Tapping the action button will close the notice. Move to the 186 // Tapping the action button will close the notice. Move to the
187 // end of the message loop to allow the closing event to propagate 187 // end of the message loop to allow the closing event to propagate
188 // to the parent dialog. The parent dialog should subsequently 188 // to the parent dialog. The parent dialog should subsequently
189 // close as well. 189 // close as well.
190 setTimeout(function() { 190 setTimeout(function() {
191 var notice = element.$$('#notice'); 191 var notice = element.$$('#notice');
192 assertFalse(!!notice); 192 assertFalse(!!notice);
193 assertFalse(element.$.dialog.opened); 193 assertFalse(element.$.dialog.open);
194 }, 0); 194 }, 0);
195 }); 195 });
196 }); 196 });
197 197
198 test('Counters', function() { 198 test('Counters', function() {
199 assertTrue(element.$.dialog.opened); 199 assertTrue(element.$.dialog.open);
200 200
201 // Initialize the browsing history pref, which should belong to the 201 // Initialize the browsing history pref, which should belong to the
202 // first checkbox in the dialog. 202 // first checkbox in the dialog.
203 element.set('prefs', { 203 element.set('prefs', {
204 browser: { 204 browser: {
205 clear_data: { 205 clear_data: {
206 browsing_history: { 206 browsing_history: {
207 key: 'browser.clear_data.browsing_history', 207 key: 'browser.clear_data.browsing_history',
208 type: chrome.settingsPrivate.PrefType.BOOLEAN, 208 type: chrome.settingsPrivate.PrefType.BOOLEAN,
209 value: true, 209 value: true,
(...skipping 21 matching lines...) Expand all
231 231
232 return { 232 return {
233 registerTests: function() { 233 registerTests: function() {
234 if (cr.isMac || cr.isWin) 234 if (cr.isMac || cr.isWin)
235 registerNativeCertificateManagerTests(); 235 registerNativeCertificateManagerTests();
236 236
237 registerClearBrowsingDataTests(); 237 registerClearBrowsingDataTests();
238 }, 238 },
239 }; 239 };
240 }); 240 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698