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

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

Issue 2868223002: [MD settings] content exceptions with embeddingOrigin as read-only (Closed)
Patch Set: unit tests Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** @fileoverview Suite of tests for site-list. */ 5 /** @fileoverview Suite of tests for site-list. */
6 6
7 /** 7 /**
8 * An example pref with 2 blocked location items and 2 allowed. This pref 8 * An example pref with 2 blocked location items and 2 allowed. This pref
9 * is also used for the All Sites category and therefore needs values for 9 * is also used for the All Sites category and therefore needs values for
10 * all types, even though some might be blank. 10 * all types, even though some might be blank.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 embeddingOrigin: 'https://[*.]foo.com', 120 embeddingOrigin: 'https://[*.]foo.com',
121 origin: 'https://[*.]foo.com', 121 origin: 'https://[*.]foo.com',
122 setting: 'block', 122 setting: 'block',
123 source: 'preference', 123 source: 'preference',
124 }, 124 },
125 ] 125 ]
126 } 126 }
127 }; 127 };
128 128
129 /** 129 /**
130 * An example pref with with and without embeddingOrigin.
dpapad 2017/05/10 21:44:57 s/with with/with
dschuyler 2017/05/10 22:05:37 Done.
131 * @type {SiteSettingsPref}
132 */
133 var prefsMixedEmbeddingOrigin = {
134 exceptions: {
135 geolocation: [
136 {
137 origin: 'https://foo.com',
138 embeddingOrigin: 'https://example.com',
139 setting: 'allow',
140 source: 'preference',
141 },
142 {
143 origin: 'https://bar.com',
144 embeddingOrigin: '',
145 setting: 'allow',
146 source: 'preference',
147 },
148 ],
149 }
150 };
151
152 /**
130 * An example pref with mixed origin and pattern. 153 * An example pref with mixed origin and pattern.
131 * @type {SiteSettingsPref} 154 * @type {SiteSettingsPref}
132 */ 155 */
133 var prefsMixedOriginAndPattern = { 156 var prefsMixedOriginAndPattern = {
134 exceptions: { 157 exceptions: {
135 auto_downloads: [], 158 auto_downloads: [],
136 background_sync: [], 159 background_sync: [],
137 camera: [], 160 camera: [],
138 cookies: [], 161 cookies: [],
139 geolocation: [ 162 geolocation: [
140 { 163 {
141 origin: 'https://foo.com', 164 origin: 'https://foo.com',
142 embeddingOrigin: '*', 165 embeddingOrigin: 'https://example.com',
143 setting: 'allow', 166 setting: 'allow',
144 source: 'preference', 167 source: 'preference',
145 }, 168 },
146 ], 169 ],
147 images: [], 170 images: [],
148 javascript: [ 171 javascript: [
149 { 172 {
150 origin: 'https://[*.]foo.com', 173 origin: 'https://[*.]foo.com',
151 embeddingOrigin: '*', 174 embeddingOrigin: '',
152 setting: 'allow', 175 setting: 'allow',
153 source: 'preference', 176 source: 'preference',
154 }, 177 },
155 ], 178 ],
156 mic: [], 179 mic: [],
157 notifications: [], 180 notifications: [],
158 plugins: [], 181 plugins: [],
159 midiDevices: [], 182 midiDevices: [],
160 protectedContent: [], 183 protectedContent: [],
161 popups: [], 184 popups: [],
162 subresource_filter: [], 185 subresource_filter: [],
163 unsandboxed_plugins: [], 186 unsandboxed_plugins: [],
164 } 187 }
165 }; 188 };
166 189
167 /** 190 /**
168 * An example pref with multiple categories and multiple allow/block 191 * An example pref with multiple categories and multiple allow/block
169 * state. 192 * state.
170 * @type {SiteSettingsPref} 193 * @type {SiteSettingsPref}
171 */ 194 */
172 var prefsVarious = { 195 var prefsVarious = {
173 exceptions: { 196 exceptions: {
174 auto_downloads: [], 197 auto_downloads: [],
175 background_sync: [], 198 background_sync: [],
176 camera: [], 199 camera: [],
177 cookies: [], 200 cookies: [],
178 geolocation: [ 201 geolocation: [
179 { 202 {
180 embeddingOrigin: 'https://foo.com', 203 embeddingOrigin: '',
181 incognito: false, 204 incognito: false,
182 origin: 'https://foo.com', 205 origin: 'https://foo.com',
183 setting: 'allow', 206 setting: 'allow',
184 source: 'preference', 207 source: 'preference',
185 }, 208 },
186 { 209 {
187 embeddingOrigin: 'https://bar.com', 210 embeddingOrigin: '',
188 incognito: false, 211 incognito: false,
189 origin: 'https://bar.com', 212 origin: 'https://bar.com',
190 setting: 'block', 213 setting: 'block',
191 source: 'preference', 214 source: 'preference',
192 }, 215 },
193 ], 216 ],
194 images: [], 217 images: [],
195 javascript: [], 218 javascript: [],
196 mic: [], 219 mic: [],
197 midiDevices: [], 220 midiDevices: [],
198 notifications: [ 221 notifications: [
199 { 222 {
200 embeddingOrigin: 'https://google.com', 223 embeddingOrigin: '',
201 incognito: false, 224 incognito: false,
202 origin: 'https://google.com', 225 origin: 'https://google.com',
203 setting: 'block', 226 setting: 'block',
204 source: 'preference', 227 source: 'preference',
205 }, 228 },
206 { 229 {
207 embeddingOrigin: 'https://bar.com', 230 embeddingOrigin: '',
208 incognito: false, 231 incognito: false,
209 origin: 'https://bar.com', 232 origin: 'https://bar.com',
210 setting: 'block', 233 setting: 'block',
211 source: 'preference', 234 source: 'preference',
212 }, 235 },
213 { 236 {
214 embeddingOrigin: 'https://foo.com', 237 embeddingOrigin: '',
215 incognito: false, 238 incognito: false,
216 origin: 'https://foo.com', 239 origin: 'https://foo.com',
217 setting: 'block', 240 setting: 'block',
218 source: 'preference', 241 source: 'preference',
219 }, 242 },
220 ], 243 ],
221 plugins: [], 244 plugins: [],
222 protectedContent: [], 245 protectedContent: [],
223 popups: [], 246 popups: [],
224 subresource_filter: [], 247 subresource_filter: [],
225 unsandboxed_plugins: [], 248 unsandboxed_plugins: [],
226 } 249 }
227 }; 250 };
228 251
229 /** 252 /**
230 * An example pref with 1 allowed location item. 253 * An example pref with 1 allowed location item.
231 * @type {SiteSettingsPref} 254 * @type {SiteSettingsPref}
232 */ 255 */
233 var prefsOneEnabled = { 256 var prefsOneEnabled = {
234 exceptions: { 257 exceptions: {
235 geolocation: [ 258 geolocation: [
236 { 259 {
237 embeddingOrigin: 'https://foo-allow.com:443', 260 embeddingOrigin: '',
238 incognito: false, 261 incognito: false,
239 origin: 'https://foo-allow.com:443', 262 origin: 'https://foo-allow.com:443',
240 setting: 'allow', 263 setting: 'allow',
241 source: 'preference', 264 source: 'preference',
242 }, 265 },
243 ] 266 ]
244 } 267 }
245 }; 268 };
246 269
247 /** 270 /**
248 * An example pref with 1 blocked location item. 271 * An example pref with 1 blocked location item.
249 * @type {SiteSettingsPref} 272 * @type {SiteSettingsPref}
250 */ 273 */
251 var prefsOneDisabled = { 274 var prefsOneDisabled = {
252 exceptions: { 275 exceptions: {
253 geolocation: [ 276 geolocation: [
254 { 277 {
255 embeddingOrigin: 'https://foo-block.com:443', 278 embeddingOrigin: '',
256 incognito: false, 279 incognito: false,
257 origin: 'https://foo-block.com:443', 280 origin: 'https://foo-block.com:443',
258 setting: 'block', 281 setting: 'block',
259 source: 'preference', 282 source: 'preference',
260 }, 283 },
261 ] 284 ]
262 } 285 }
263 }; 286 };
264 287
265 /** 288 /**
266 * An example Cookies pref with 1 in each of the three categories. 289 * An example Cookies pref with 1 in each of the three categories.
267 * @type {SiteSettingsPref} 290 * @type {SiteSettingsPref}
268 */ 291 */
269 var prefsSessionOnly = { 292 var prefsSessionOnly = {
270 exceptions: { 293 exceptions: {
271 cookies: [ 294 cookies: [
272 { 295 {
273 embeddingOrigin: 'http://foo-block.com', 296 embeddingOrigin: '',
274 incognito: false, 297 incognito: false,
275 origin: 'http://foo-block.com', 298 origin: 'http://foo-block.com',
276 setting: 'block', 299 setting: 'block',
277 source: 'preference', 300 source: 'preference',
278 }, 301 },
279 { 302 {
280 embeddingOrigin: 'http://foo-allow.com', 303 embeddingOrigin: '',
281 incognito: false, 304 incognito: false,
282 origin: 'http://foo-allow.com', 305 origin: 'http://foo-allow.com',
283 setting: 'allow', 306 setting: 'allow',
284 source: 'preference', 307 source: 'preference',
285 }, 308 },
286 { 309 {
287 embeddingOrigin: 'http://foo-session.com', 310 embeddingOrigin: '',
288 incognito: false, 311 incognito: false,
289 origin: 'http://foo-session.com', 312 origin: 'http://foo-session.com',
290 setting: 'session_only', 313 setting: 'session_only',
291 source: 'preference', 314 source: 'preference',
292 }, 315 },
293 ] 316 ]
294 } 317 }
295 }; 318 };
296 319
297 /** 320 /**
298 * An example Cookies pref with mixed incognito and regular settings. 321 * An example Cookies pref with mixed incognito and regular settings.
299 * @type {SiteSettingsPref} 322 * @type {SiteSettingsPref}
300 */ 323 */
301 var prefsIncognito = { 324 var prefsIncognito = {
302 exceptions: { 325 exceptions: {
303 cookies: [ 326 cookies: [
304 // foo.com is blocked for regular sessions. 327 // foo.com is blocked for regular sessions.
305 { 328 {
306 embeddingOrigin: 'http://foo.com', 329 embeddingOrigin: '',
307 incognito: false, 330 incognito: false,
308 origin: 'http://foo.com', 331 origin: 'http://foo.com',
309 setting: 'block', 332 setting: 'block',
310 source: 'preference', 333 source: 'preference',
311 }, 334 },
312 // bar.com is an allowed incognito item without an embedder. 335 // bar.com is an allowed incognito item.
313 { 336 {
314 embeddingOrigin: '', 337 embeddingOrigin: '',
315 incognito: true, 338 incognito: true,
316 origin: 'http://bar.com', 339 origin: 'http://bar.com',
317 setting: 'allow', 340 setting: 'allow',
318 source: 'preference', 341 source: 'preference',
319 }, 342 },
320 // foo.com is allowed in incognito (overridden). 343 // foo.com is allowed in incognito (overridden).
321 { 344 {
322 embeddingOrigin: 'http://foo.com', 345 embeddingOrigin: '',
323 incognito: true, 346 incognito: true,
324 origin: 'http://foo.com', 347 origin: 'http://foo.com',
325 setting: 'allow', 348 setting: 'allow',
326 source: 'preference', 349 source: 'preference',
327 }, 350 },
328 351
329 ] 352 ]
330 } 353 }
331 }; 354 };
332 355
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 assertMenu(['Allow', 'Clear on exit', 'Edit', 'Remove'], testElement); 699 assertMenu(['Allow', 'Clear on exit', 'Edit', 'Remove'], testElement);
677 700
678 // Select 'Remove' from menu. 701 // Select 'Remove' from menu.
679 var remove = testElement.$.reset; 702 var remove = testElement.$.reset;
680 assertTrue(!!remove); 703 assertTrue(!!remove);
681 MockInteractions.tap(remove); 704 MockInteractions.tap(remove);
682 return browserProxy.whenCalled('resetCategoryPermissionForOrigin'); 705 return browserProxy.whenCalled('resetCategoryPermissionForOrigin');
683 }) 706 })
684 .then(function(args) { 707 .then(function(args) {
685 assertEquals('http://foo.com', args[0]); 708 assertEquals('http://foo.com', args[0]);
686 assertEquals('http://foo.com', args[1]); 709 assertEquals('', args[1]);
687 assertEquals(contentType, args[2]); 710 assertEquals(contentType, args[2]);
688 assertFalse(args[3]); // Incognito. 711 assertFalse(args[3]); // Incognito.
689 }); 712 });
690 }); 713 });
691 714
692 test('initial INCOGNITO ALLOW state is correct', function() { 715 test('initial INCOGNITO ALLOW state is correct', function() {
693 var contentType = settings.ContentSettingsTypes.COOKIES; 716 var contentType = settings.ContentSettingsTypes.COOKIES;
694 var categorySubtype = settings.PermissionValues.ALLOW; 717 var categorySubtype = settings.PermissionValues.ALLOW;
695 setUpCategory(contentType, categorySubtype, prefsIncognito); 718 setUpCategory(contentType, categorySubtype, prefsIncognito);
696 return browserProxy.whenCalled('getExceptionList') 719 return browserProxy.whenCalled('getExceptionList')
(...skipping 17 matching lines...) Expand all
714 737
715 // Select 'Remove' from menu on 'foo.com'. 738 // Select 'Remove' from menu on 'foo.com'.
716 openActionMenu(1); 739 openActionMenu(1);
717 var remove = testElement.$.reset; 740 var remove = testElement.$.reset;
718 assertTrue(!!remove); 741 assertTrue(!!remove);
719 MockInteractions.tap(remove); 742 MockInteractions.tap(remove);
720 return browserProxy.whenCalled('resetCategoryPermissionForOrigin'); 743 return browserProxy.whenCalled('resetCategoryPermissionForOrigin');
721 }) 744 })
722 .then(function(args) { 745 .then(function(args) {
723 assertEquals('http://foo.com', args[0]); 746 assertEquals('http://foo.com', args[0]);
724 assertEquals('http://foo.com', args[1]); 747 assertEquals('', args[1]);
725 assertEquals(contentType, args[2]); 748 assertEquals(contentType, args[2]);
726 assertTrue(args[3]); // Incognito. 749 assertTrue(args[3]); // Incognito.
727 }); 750 });
728 }); 751 });
729 752
730 test('reset button works for read-only content types', function() { 753 test('reset button works for read-only content types', function() {
731 testElement.readOnlyList = true; 754 testElement.readOnlyList = true;
732 Polymer.dom.flush(); 755 Polymer.dom.flush();
733 756
734 var contentType = settings.ContentSettingsTypes.GEOLOCATION; 757 var contentType = settings.ContentSettingsTypes.GEOLOCATION;
(...skipping 21 matching lines...) Expand all
756 // Assert reset button is visible. 779 // Assert reset button is visible.
757 var resetButton = item.querySelector('#resetSite'); 780 var resetButton = item.querySelector('#resetSite');
758 assertTrue(!!resetButton); 781 assertTrue(!!resetButton);
759 assertFalse(resetButton.hidden); 782 assertFalse(resetButton.hidden);
760 783
761 MockInteractions.tap(resetButton); 784 MockInteractions.tap(resetButton);
762 return browserProxy.whenCalled('resetCategoryPermissionForOrigin'); 785 return browserProxy.whenCalled('resetCategoryPermissionForOrigin');
763 }) 786 })
764 .then(function(args) { 787 .then(function(args) {
765 assertEquals('https://foo-allow.com:443', args[0]); 788 assertEquals('https://foo-allow.com:443', args[0]);
766 assertEquals('https://foo-allow.com:443', args[1]); 789 assertEquals('', args[1]);
767 assertEquals(contentType, args[2]); 790 assertEquals(contentType, args[2]);
768 }); 791 });
769 }); 792 });
770 793
771 test('edit action menu opens edit exception dialog', function() { 794 test('edit action menu opens edit exception dialog', function() {
772 setUpCategory( 795 setUpCategory(
773 settings.ContentSettingsTypes.COOKIES, 796 settings.ContentSettingsTypes.COOKIES,
774 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); 797 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly);
775 798
776 return browserProxy.whenCalled('getExceptionList').then(function() { 799 return browserProxy.whenCalled('getExceptionList').then(function() {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 MockInteractions.tap(clickable); 1028 MockInteractions.tap(clickable);
1006 if (testElement.sites.length == 1) { 1029 if (testElement.sites.length == 1) {
1007 assertEquals( 1030 assertEquals(
1008 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, 1031 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin,
1009 testElement.sites[0].displayName); 1032 testElement.sites[0].displayName);
1010 } 1033 }
1011 }); 1034 });
1012 }); 1035 });
1013 }); 1036 });
1014 1037
1038 test('Mixed embeddingOrigin', function() {
1039 setUpCategory(
1040 settings.ContentSettingsTypes.GEOLOCATION,
dpapad 2017/05/10 21:44:57 Should we use a different category for this test,
dschuyler 2017/05/10 22:05:37 Done.
1041 settings.PermissionValues.ALLOW, prefsMixedEmbeddingOrigin);
1042 return browserProxy.whenCalled('getExceptionList')
1043 .then(function(contentType) {
1044 // Required for firstItem to be found below.
1045 Polymer.dom.flush();
1046 // Validate that embeddingOrigin sites cannot be edited.
1047 var firstItem = testElement.$.listContainer.children[0];
1048 assertTrue(firstItem.querySelector('#actionMenuButton').hidden);
1049 assertFalse(firstItem.querySelector('#resetSite').hidden);
1050 // Validate that non-embeddingOrigin sites can be edited.
1051 var secondItem = testElement.$.listContainer.children[1];
1052 assertFalse(secondItem.querySelector('#actionMenuButton').hidden);
1053 assertTrue(secondItem.querySelector('#resetSite').hidden);
1054 });
1055 });
1056
1015 test('Mixed schemes (present and absent)', function() { 1057 test('Mixed schemes (present and absent)', function() {
1016 // Prefs: One item with scheme and one without. 1058 // Prefs: One item with scheme and one without.
1017 setUpCategory( 1059 setUpCategory(
1018 settings.ContentSettingsTypes.GEOLOCATION, 1060 settings.ContentSettingsTypes.GEOLOCATION,
1019 settings.PermissionValues.ALLOW, prefsMixedSchemes); 1061 settings.PermissionValues.ALLOW, prefsMixedSchemes);
1020 return browserProxy.whenCalled('getExceptionList') 1062 return browserProxy.whenCalled('getExceptionList')
1021 .then(function(contentType) { 1063 .then(function(contentType) {
1022 // No further checks needed. If this fails, it will hang the test. 1064 // No further checks needed. If this fails, it will hang the test.
1023 }); 1065 });
1024 }); 1066 });
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 input.value = expectedPattern; 1247 input.value = expectedPattern;
1206 input.fire('input'); 1248 input.fire('input');
1207 1249
1208 return browserProxy.whenCalled('isPatternValid').then(function(pattern) { 1250 return browserProxy.whenCalled('isPatternValid').then(function(pattern) {
1209 assertEquals(expectedPattern, pattern); 1251 assertEquals(expectedPattern, pattern);
1210 assertTrue(actionButton.disabled); 1252 assertTrue(actionButton.disabled);
1211 assertTrue(input.invalid); 1253 assertTrue(input.invalid);
1212 }); 1254 });
1213 }); 1255 });
1214 }); 1256 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698