Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 cr.define('site_list', function() { | 6 cr.define('site_list', function() { |
| 7 function registerTests() { | 7 function registerTests() { |
| 8 suite('SiteList', function() { | 8 suite('SiteList', function() { |
| 9 /** | 9 /** |
| 10 * A site list element created before each test. | 10 * A site list element created before each test. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 { | 211 { |
| 212 embeddingOrigin: 'https://foo-block.com:443', | 212 embeddingOrigin: 'https://foo-block.com:443', |
| 213 origin: 'https://foo-block.com:443', | 213 origin: 'https://foo-block.com:443', |
| 214 setting: 'block', | 214 setting: 'block', |
| 215 source: 'preference', | 215 source: 'preference', |
| 216 }, | 216 }, |
| 217 ] | 217 ] |
| 218 } | 218 } |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 /** | |
| 222 * An example Cookies pref with 1 in each of the three categories. | |
| 223 * @type {SiteSettingsPref} | |
| 224 */ | |
| 225 var prefsSessionOnly = { | |
| 226 exceptions: { | |
| 227 cookies: [ | |
| 228 { | |
| 229 embeddingOrigin: 'http://foo-block.com', | |
| 230 origin: 'http://foo-block.com', | |
| 231 setting: 'block', | |
| 232 source: 'preference', | |
| 233 }, | |
| 234 { | |
| 235 embeddingOrigin: 'http://foo-allow.com', | |
| 236 origin: 'http://foo-allow.com', | |
| 237 setting: 'allow', | |
| 238 source: 'preference', | |
| 239 }, | |
| 240 { | |
| 241 embeddingOrigin: 'http://foo-session.com', | |
| 242 origin: 'http://foo-session.com', | |
| 243 setting: 'session_only', | |
| 244 source: 'preference', | |
| 245 }, | |
| 246 ] | |
| 247 } | |
| 248 }; | |
| 249 | |
| 221 // Import necessary html before running suite. | 250 // Import necessary html before running suite. |
| 222 suiteSetup(function() { | 251 suiteSetup(function() { |
| 223 CrSettingsPrefs.setInitialized(); | 252 CrSettingsPrefs.setInitialized(); |
| 224 return PolymerTest.importHtml( | 253 return PolymerTest.importHtml( |
| 225 'chrome://md-settings/site_settings/site_list.html'); | 254 'chrome://md-settings/site_settings/site_list.html'); |
| 226 }); | 255 }); |
| 227 | 256 |
| 228 suiteTeardown(function() { | 257 suiteTeardown(function() { |
| 229 CrSettingsPrefs.resetForTesting(); | 258 CrSettingsPrefs.resetForTesting(); |
| 230 }); | 259 }); |
| 231 | 260 |
| 232 // Initialize a site-list before each test. | 261 // Initialize a site-list before each test. |
| 233 setup(function() { | 262 setup(function() { |
| 234 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); | 263 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); |
| 235 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; | 264 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; |
| 236 PolymerTest.clearBody(); | 265 PolymerTest.clearBody(); |
| 237 testElement = document.createElement('settings-site-list'); | 266 testElement = document.createElement('settings-site-list'); |
| 238 document.body.appendChild(testElement); | 267 document.body.appendChild(testElement); |
| 239 }); | 268 }); |
| 240 | 269 |
| 241 /** | 270 /** |
| 242 * Asserts if a menu action is incorrectly hidden. | 271 * Asserts the menu looks as expected. |
| 272 * @param {Array<string>} items The items expected to show in the menu. | |
| 243 * @param {!HTMLElement} parentElement The parent node to start looking | 273 * @param {!HTMLElement} parentElement The parent node to start looking |
| 244 * in. | 274 * in. |
| 245 * @param {string} textForHiddenAction Text content of the only node that | |
| 246 * should be hidden. | |
| 247 */ | 275 */ |
| 248 function assertMenuActionHidden(parentElement, textForHiddenAction) { | 276 function assertMenu(items, parentElement) { |
| 249 var listItem = parentElement.$.listContainer.children[0]; | 277 var listItem = parentElement.$.listContainer.children[0]; |
| 250 var menuItems = | 278 var menuItems = |
| 251 listItem.querySelectorAll('paper-menu-button paper-item'); | 279 listItem.querySelectorAll('paper-menu-button paper-item'); |
|
michaelpg
2016/06/09 18:43:43
Use the platform, Luke!
var menuItems = listItem.
Finnur
2016/06/10 14:20:46
Hey, neat. :)
| |
| 252 assertNotEquals(0, menuItems.length); | 280 var i = 0; |
| 253 | |
| 254 var found = false; | |
| 255 menuItems.forEach(function(item) { | 281 menuItems.forEach(function(item) { |
| 256 var text = item.textContent.trim(); | 282 var text = item.textContent.trim(); |
| 257 if (text == textForHiddenAction) | 283 if (!item.hidden) { |
| 258 found = true; | 284 assertEquals(items[i], text); |
| 259 assertEquals(text == textForHiddenAction, item.hidden); | 285 ++i; |
| 286 } | |
| 260 }); | 287 }); |
| 261 assertTrue(found); | 288 assertEquals(items.length, i); |
| 262 } | 289 } |
| 263 | 290 |
| 264 /** | 291 /** |
| 265 * Configures the test element as a location category. | 292 * Configures the test element for a particular category. |
| 266 * @param {settings.PermissionValues} subtype Type of list to use: ALLOW | 293 * @param {settings.ContentSettingsTypes} category The category to setup. |
| 267 * or BLOCK. | 294 * @param {settings.PermissionValues} subtype Type of list to use. |
| 268 * @param Array<dictionary> prefs The prefs to use. | 295 * @param {Array<dictionary>} prefs The prefs to use. |
| 269 */ | 296 */ |
| 270 function setupLocationCategory(subtype, prefs) { | 297 function setupCategory(category, subtype, prefs) { |
| 271 browserProxy.setPrefs(prefs); | 298 browserProxy.setPrefs(prefs); |
| 272 testElement.categorySubtype = subtype; | 299 if (category == settings.ALL_SITES) { |
| 273 testElement.categoryEnabled = true; | 300 testElement.categorySubtype = settings.INVALID_CATEGORY_SUBTYPE; |
| 274 testElement.allSites = false; | 301 testElement.allSites = true; |
| 302 } else { | |
| 303 testElement.categorySubtype = subtype; | |
| 304 testElement.allSites = false; | |
| 305 } | |
| 306 // Some route is needed, but the actual route doesn't matter. | |
| 275 testElement.currentRoute = { | 307 testElement.currentRoute = { |
| 276 page: 'dummy', | 308 page: 'dummy', |
| 277 section: 'privacy', | 309 section: 'privacy', |
| 278 subpage: ['site-settings', 'site-settings-category-location'], | 310 subpage: ['site-settings', 'site-settings-category-location'], |
| 279 }; | 311 }; |
| 280 testElement.category = settings.ContentSettingsTypes.GEOLOCATION; | 312 testElement.category = category; |
| 281 } | |
| 282 | |
| 283 /** | |
| 284 * Configures the test element as the all sites category. | |
| 285 * @param {dictionary} prefs The prefs to use. | |
| 286 */ | |
| 287 function setupAllSitesCategory(prefs) { | |
| 288 browserProxy.setPrefs(prefs); | |
| 289 testElement.categorySubtype = settings.INVALID_CATEGORY_SUBTYPE; | |
| 290 testElement.categoryEnabled = true; | |
| 291 testElement.allSites = true; | |
| 292 testElement.prefs = prefs; | |
| 293 testElement.currentRoute = { | |
| 294 page: 'dummy', | |
| 295 section: 'privacy', | |
| 296 subpage: ['site-settings', 'site-settings-category-location'], | |
| 297 }; | |
| 298 testElement.category = settings.ALL_SITES; | |
| 299 } | 313 } |
| 300 | 314 |
| 301 test('getExceptionList API used', function() { | 315 test('getExceptionList API used', function() { |
| 302 setupLocationCategory(settings.PermissionValues.ALLOW, prefsEmpty); | 316 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 317 settings.PermissionValues.ALLOW, prefsEmpty); | |
| 303 return browserProxy.whenCalled('getExceptionList').then( | 318 return browserProxy.whenCalled('getExceptionList').then( |
| 304 function(contentType) { | 319 function(contentType) { |
| 305 assertEquals( | 320 assertEquals( |
| 306 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 321 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 307 }); | 322 }); |
| 308 }); | 323 }); |
| 309 | 324 |
| 310 test('Empty list', function() { | 325 test('Empty list', function() { |
| 311 setupLocationCategory(settings.PermissionValues.ALLOW, prefsEmpty); | 326 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 327 settings.PermissionValues.ALLOW, prefsEmpty); | |
| 312 return browserProxy.whenCalled('getExceptionList').then( | 328 return browserProxy.whenCalled('getExceptionList').then( |
| 313 function(contentType) { | 329 function(contentType) { |
| 314 assertEquals( | 330 assertEquals( |
| 315 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 331 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 316 | 332 |
| 317 assertEquals(0, testElement.sites.length); | 333 assertEquals(0, testElement.sites.length); |
| 318 | 334 |
| 319 assertEquals( | 335 assertEquals( |
| 320 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 336 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 321 assertEquals('Allow - 0', testElement.$.header.innerText.trim()); | 337 assertEquals('Allow - 0', testElement.$.header.innerText.trim()); |
| 322 | 338 |
| 323 // Site list should not show, no matter what category default is set | 339 // Site list should not show, no matter what category default is set |
| 324 // to. | 340 // to. |
| 325 assertTrue(testElement.$.category.hidden); | 341 assertTrue(testElement.$.category.hidden); |
| 326 browserProxy.resetResolver('getExceptionList'); | 342 browserProxy.resetResolver('getExceptionList'); |
| 327 testElement.categoryEnabled = false; | 343 testElement.categoryEnabled = false; |
| 328 return browserProxy.whenCalled('getExceptionList').then( | 344 return browserProxy.whenCalled('getExceptionList').then( |
| 329 function(contentType) { | 345 function(contentType) { |
| 330 assertTrue(testElement.$.category.hidden); | 346 assertTrue(testElement.$.category.hidden); |
| 331 assertEquals('Exceptions - 0', | 347 assertEquals('Exceptions - 0', |
| 332 testElement.$.header.innerText.trim()); | 348 testElement.$.header.innerText.trim()); |
| 333 }); | 349 }); |
| 334 }); | 350 }); |
| 335 }); | 351 }); |
| 336 | 352 |
| 337 test('initial ALLOW state is correct', function() { | 353 test('initial ALLOW state is correct', function() { |
| 338 setupLocationCategory(settings.PermissionValues.ALLOW, prefs); | 354 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 355 settings.PermissionValues.ALLOW, prefs); | |
| 339 return browserProxy.whenCalled('getExceptionList').then( | 356 return browserProxy.whenCalled('getExceptionList').then( |
| 340 function(contentType) { | 357 function(contentType) { |
| 341 assertEquals( | 358 assertEquals( |
| 342 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 359 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 343 | 360 |
| 344 assertEquals(2, testElement.sites.length); | 361 assertEquals(2, testElement.sites.length); |
| 345 assertEquals(prefs.exceptions.geolocation[1].origin, | 362 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 346 testElement.sites[0].origin); | 363 testElement.sites[0].origin); |
| 347 assertEquals( | 364 assertEquals( |
| 348 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 365 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 349 Polymer.dom.flush(); // Populates action menu. | 366 Polymer.dom.flush(); // Populates action menu. |
| 350 assertMenuActionHidden(testElement, 'Allow'); | 367 assertMenu(['Block', 'Reset to ask'], testElement); |
| 351 assertEquals('Allow - 2', testElement.$.header.innerText.trim()); | 368 assertEquals('Allow - 2', testElement.$.header.innerText.trim()); |
| 352 | 369 |
| 353 // Site list should show, no matter what category default is set to. | 370 // Site list should show, no matter what category default is set to. |
| 354 assertFalse(testElement.$.category.hidden); | 371 assertFalse(testElement.$.category.hidden); |
| 355 browserProxy.resetResolver('getExceptionList'); | 372 browserProxy.resetResolver('getExceptionList'); |
| 356 testElement.categoryEnabled = false; | 373 testElement.categoryEnabled = false; |
| 357 return browserProxy.whenCalled('getExceptionList').then( | 374 return browserProxy.whenCalled('getExceptionList').then( |
| 358 function(contentType) { | 375 function(contentType) { |
| 359 assertFalse(testElement.$.category.hidden); | 376 assertFalse(testElement.$.category.hidden); |
| 360 assertEquals('Exceptions - 2', testElement.$.header.innerText); | 377 assertEquals('Exceptions - 2', testElement.$.header.innerText); |
| 361 }); | 378 }); |
| 362 }); | 379 }); |
| 363 }); | 380 }); |
| 364 | 381 |
| 365 test('initial BLOCK state is correct', function() { | 382 test('initial BLOCK state is correct', function() { |
| 366 setupLocationCategory(settings.PermissionValues.BLOCK, prefs); | 383 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 384 settings.PermissionValues.BLOCK, prefs); | |
| 367 return browserProxy.whenCalled('getExceptionList').then( | 385 return browserProxy.whenCalled('getExceptionList').then( |
| 368 function(contentType) { | 386 function(contentType) { |
| 369 assertEquals( | 387 assertEquals( |
| 370 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 388 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 371 | 389 |
| 372 assertEquals(2, testElement.sites.length); | 390 assertEquals(2, testElement.sites.length); |
| 373 assertEquals(prefs.exceptions.geolocation[3].origin, | 391 assertEquals(prefs.exceptions.geolocation[3].origin, |
| 374 testElement.sites[0].origin); | 392 testElement.sites[0].origin); |
| 375 | 393 |
| 376 assertEquals( | 394 assertEquals( |
| 377 settings.PermissionValues.BLOCK, testElement.categorySubtype); | 395 settings.PermissionValues.BLOCK, testElement.categorySubtype); |
| 378 Polymer.dom.flush(); // Populates action menu. | 396 Polymer.dom.flush(); // Populates action menu. |
| 379 assertMenuActionHidden(testElement, 'Block'); | 397 assertMenu(['Allow', 'Reset to ask'], testElement); |
| 380 assertEquals('Block - 2', testElement.$.header.innerText.trim()); | 398 assertEquals('Block - 2', testElement.$.header.innerText.trim()); |
| 381 | 399 |
| 382 // Site list should only show when category default is enabled. | 400 // Site list should only show when category default is enabled. |
| 383 assertFalse(testElement.$.category.hidden); | 401 assertFalse(testElement.$.category.hidden); |
| 384 browserProxy.resetResolver('getExceptionList'); | 402 browserProxy.resetResolver('getExceptionList'); |
| 385 testElement.categoryEnabled = false; | 403 testElement.categoryEnabled = false; |
| 386 return browserProxy.whenCalled('getExceptionList').then( | 404 return browserProxy.whenCalled('getExceptionList').then( |
| 387 function(contentType) { | 405 function(contentType) { |
| 388 assertTrue(testElement.$.category.hidden); | 406 assertTrue(testElement.$.category.hidden); |
| 389 }); | 407 }); |
| 390 }); | 408 }); |
| 391 }); | 409 }); |
| 392 | 410 |
| 411 test('initial SESSION ONLY state is correct', function() { | |
| 412 setupCategory(settings.ContentSettingsTypes.COOKIES, | |
| 413 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); | |
| 414 return browserProxy.whenCalled('getExceptionList').then( | |
| 415 function(contentType) { | |
| 416 assertEquals( | |
| 417 settings.ContentSettingsTypes.COOKIES, contentType); | |
| 418 | |
| 419 assertEquals(1, testElement.sites.length); | |
| 420 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, | |
| 421 testElement.sites[0].origin); | |
| 422 | |
| 423 assertEquals(settings.PermissionValues.SESSION_ONLY, | |
| 424 testElement.categorySubtype); | |
| 425 Polymer.dom.flush(); // Populates action menu. | |
| 426 assertMenu(['Allow', 'Block', 'Reset to ask'], testElement); | |
| 427 assertEquals('Clear on exit - 1', | |
| 428 testElement.$.header.innerText.trim()); | |
| 429 | |
| 430 // Site list should show, no matter what category default is set to. | |
| 431 assertFalse(testElement.$.category.hidden); | |
| 432 browserProxy.resetResolver('getExceptionList'); | |
| 433 testElement.categoryEnabled = false; | |
| 434 return browserProxy.whenCalled('getExceptionList').then( | |
| 435 function(contentType) { | |
|
michaelpg
2016/06/09 18:43:43
nit: 4-space indent
Finnur
2016/06/10 14:20:46
Done.
| |
| 436 assertFalse(testElement.$.category.hidden); | |
| 437 assertEquals('Clear on exit - 1', | |
| 438 testElement.$.header.innerText); | |
| 439 }); | |
| 440 }); | |
| 441 }); | |
| 442 | |
| 393 test('list items shown and clickable when data is present', function() { | 443 test('list items shown and clickable when data is present', function() { |
| 394 setupLocationCategory(settings.PermissionValues.ALLOW, prefs); | 444 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 445 settings.PermissionValues.ALLOW, prefs); | |
| 395 return browserProxy.whenCalled('getExceptionList').then( | 446 return browserProxy.whenCalled('getExceptionList').then( |
| 396 function(contentType) { | 447 function(contentType) { |
| 397 assertEquals( | 448 assertEquals( |
| 398 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 449 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 399 | 450 |
| 400 // Required for firstItem to be found below. | 451 // Required for firstItem to be found below. |
| 401 Polymer.dom.flush(); | 452 Polymer.dom.flush(); |
| 402 | 453 |
| 403 // Validate that the sites gets populated from pre-canned prefs. | 454 // Validate that the sites gets populated from pre-canned prefs. |
| 404 assertEquals(2, testElement.sites.length); | 455 assertEquals(2, testElement.sites.length); |
| 405 assertEquals(prefs.exceptions.geolocation[1].origin, | 456 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 406 testElement.sites[0].origin); | 457 testElement.sites[0].origin); |
| 407 assertEquals(undefined, testElement.selectedOrigin); | 458 assertEquals(undefined, testElement.selectedOrigin); |
| 408 | 459 |
| 409 // Validate that the sites are shown in UI and can be selected. | 460 // Validate that the sites are shown in UI and can be selected. |
| 410 var firstItem = testElement.$.listContainer.children[0]; | 461 var firstItem = testElement.$.listContainer.children[0]; |
| 411 var clickable = firstItem.querySelector('.middle'); | 462 var clickable = firstItem.querySelector('.middle'); |
| 412 assertNotEquals(undefined, clickable); | 463 assertNotEquals(undefined, clickable); |
| 413 MockInteractions.tap(clickable); | 464 MockInteractions.tap(clickable); |
| 414 assertEquals(prefs.exceptions.geolocation[1].origin, | 465 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 415 testElement.selectedSite.origin); | 466 testElement.selectedSite.origin); |
| 416 }); | 467 }); |
| 417 }); | 468 }); |
| 418 | 469 |
| 419 test('Block list open when Allow list is empty', function() { | 470 test('Block list open when Allow list is empty', function() { |
| 420 // Prefs: One item in Block list, nothing in Allow list. | 471 // Prefs: One item in Block list, nothing in Allow list. |
| 421 setupLocationCategory(settings.PermissionValues.BLOCK, | 472 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 422 prefsOneDisabled); | 473 settings.PermissionValues.BLOCK, prefsOneDisabled); |
| 423 return browserProxy.whenCalled('getExceptionList').then( | 474 return browserProxy.whenCalled('getExceptionList').then( |
| 424 function(contentType) { | 475 function(contentType) { |
| 425 assertEquals( | 476 assertEquals( |
| 426 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 477 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 427 | 478 |
| 428 assertFalse(testElement.$.category.hidden); | 479 assertFalse(testElement.$.category.hidden); |
| 429 assertTrue(testElement.$.category.opened); | 480 assertTrue(testElement.$.category.opened); |
| 430 }).then(function() { | 481 }).then(function() { |
| 431 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 482 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 432 }); | 483 }); |
| 433 }); | 484 }); |
| 434 | 485 |
| 435 test('Block list closed when Allow list is not empty', function() { | 486 test('Block list closed when Allow list is not empty', function() { |
| 436 // Prefs: Items in both Block and Allow list. | 487 // Prefs: Items in both Block and Allow list. |
| 437 setupLocationCategory(settings.PermissionValues.BLOCK, prefs); | 488 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 489 settings.PermissionValues.BLOCK, prefs); | |
| 438 return browserProxy.whenCalled('getExceptionList').then( | 490 return browserProxy.whenCalled('getExceptionList').then( |
| 439 function(contentType) { | 491 function(contentType) { |
| 440 assertEquals( | 492 assertEquals( |
| 441 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 493 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 442 | 494 |
| 443 assertFalse(testElement.$.category.hidden); | 495 assertFalse(testElement.$.category.hidden); |
| 444 assertFalse(testElement.$.category.opened); | 496 assertFalse(testElement.$.category.opened); |
| 445 assertEquals(0, testElement.$.listContainer.offsetHeight); | 497 assertEquals(0, testElement.$.listContainer.offsetHeight); |
| 446 }); | 498 }); |
| 447 }); | 499 }); |
| 448 | 500 |
| 449 test('Allow list is always open (Block list empty)', function() { | 501 test('Allow list is always open (Block list empty)', function() { |
| 450 // Prefs: One item in Allow list, nothing in Block list. | 502 // Prefs: One item in Allow list, nothing in Block list. |
| 451 setupLocationCategory( | 503 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 452 settings.PermissionValues.ALLOW, prefsOneEnabled); | 504 settings.PermissionValues.ALLOW, prefsOneEnabled); |
| 453 return browserProxy.whenCalled('getExceptionList').then( | 505 return browserProxy.whenCalled('getExceptionList').then( |
| 454 function(contentType) { | 506 function(contentType) { |
| 455 assertEquals( | 507 assertEquals( |
| 456 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 508 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 457 | 509 |
| 458 assertFalse(testElement.$.category.hidden); | 510 assertFalse(testElement.$.category.hidden); |
| 459 assertTrue(testElement.$.category.opened); | 511 assertTrue(testElement.$.category.opened); |
| 460 }).then(function() { | 512 }).then(function() { |
| 461 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 513 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 462 }); | 514 }); |
| 463 }); | 515 }); |
| 464 | 516 |
| 465 test('Allow list is always open (Block list non-empty)', function() { | 517 test('Allow list is always open (Block list non-empty)', function() { |
| 466 // Prefs: Items in both Block and Allow list. | 518 // Prefs: Items in both Block and Allow list. |
| 467 setupLocationCategory(settings.PermissionValues.ALLOW, prefs); | 519 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 520 settings.PermissionValues.ALLOW, prefs); | |
| 468 return browserProxy.whenCalled('getExceptionList').then( | 521 return browserProxy.whenCalled('getExceptionList').then( |
| 469 function(contentType) { | 522 function(contentType) { |
| 470 assertEquals( | 523 assertEquals( |
| 471 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 524 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 472 | 525 |
| 473 assertFalse(testElement.$.category.hidden); | 526 assertFalse(testElement.$.category.hidden); |
| 474 assertTrue(testElement.$.category.opened); | 527 assertTrue(testElement.$.category.opened); |
| 475 }).then(function() { | 528 }).then(function() { |
| 476 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 529 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 477 }); | 530 }); |
| 478 }); | 531 }); |
| 479 | 532 |
| 480 test('Block list hidden when empty', function() { | 533 test('Block list hidden when empty', function() { |
| 481 // Prefs: One item in Allow list, nothing in Block list. | 534 // Prefs: One item in Allow list, nothing in Block list. |
| 482 setupLocationCategory( | 535 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 483 settings.PermissionValues.BLOCK, prefsOneEnabled); | 536 settings.PermissionValues.BLOCK, prefsOneEnabled); |
| 484 return browserProxy.whenCalled('getExceptionList').then( | 537 return browserProxy.whenCalled('getExceptionList').then( |
| 485 function(contentType) { | 538 function(contentType) { |
| 486 assertEquals( | 539 assertEquals( |
| 487 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 540 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 488 | 541 |
| 489 assertTrue(testElement.$.category.hidden); | 542 assertTrue(testElement.$.category.hidden); |
| 490 }); | 543 }); |
| 491 }); | 544 }); |
| 492 | 545 |
| 493 test('Allow list hidden when empty', function() { | 546 test('Allow list hidden when empty', function() { |
| 494 // Prefs: One item in Block list, nothing in Allow list. | 547 // Prefs: One item in Block list, nothing in Allow list. |
| 495 setupLocationCategory(settings.PermissionValues.ALLOW, | 548 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 496 prefsOneDisabled); | 549 settings.PermissionValues.ALLOW, prefsOneDisabled); |
| 497 return browserProxy.whenCalled('getExceptionList').then( | 550 return browserProxy.whenCalled('getExceptionList').then( |
| 498 function(contentType) { | 551 function(contentType) { |
| 499 assertEquals( | 552 assertEquals( |
| 500 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 553 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 501 | 554 |
| 502 assertTrue(testElement.$.category.hidden); | 555 assertTrue(testElement.$.category.hidden); |
| 503 }); | 556 }); |
| 504 }); | 557 }); |
| 505 | 558 |
| 506 test('All sites category', function() { | 559 test('All sites category', function() { |
| 507 // Prefs: Multiple and overlapping sites. | 560 // Prefs: Multiple and overlapping sites. |
| 508 setupAllSitesCategory(prefsVarious); | 561 setupCategory(settings.ALL_SITES, '', prefsVarious); |
| 509 | 562 |
| 510 return browserProxy.whenCalled('getExceptionList').then( | 563 return browserProxy.whenCalled('getExceptionList').then( |
| 511 function(contentType) { | 564 function(contentType) { |
| 512 // Use resolver to ensure asserts bubble up to the framework with | 565 // Use resolver to ensure asserts bubble up to the framework with |
| 513 // meaningful errors. | 566 // meaningful errors. |
| 514 var resolver = new PromiseResolver(); | 567 var resolver = new PromiseResolver(); |
| 515 testElement.async(resolver.resolve); | 568 testElement.async(resolver.resolve); |
| 516 return resolver.promise.then(function() { | 569 return resolver.promise.then(function() { |
| 517 // All Sites calls getExceptionList for all categories, starting | 570 // All Sites calls getExceptionList for all categories, starting |
| 518 // with Cookies. | 571 // with Cookies. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 541 assertNotEquals(undefined, clickable); | 594 assertNotEquals(undefined, clickable); |
| 542 MockInteractions.tap(clickable); | 595 MockInteractions.tap(clickable); |
| 543 assertEquals(prefsVarious.exceptions.geolocation[0].origin, | 596 assertEquals(prefsVarious.exceptions.geolocation[0].origin, |
| 544 testElement.selectedSite.origin); | 597 testElement.selectedSite.origin); |
| 545 }); | 598 }); |
| 546 }); | 599 }); |
| 547 }); | 600 }); |
| 548 | 601 |
| 549 test('All sites mixed pattern and origin', function() { | 602 test('All sites mixed pattern and origin', function() { |
| 550 // Prefs: One site, represented as origin and pattern. | 603 // Prefs: One site, represented as origin and pattern. |
| 551 setupAllSitesCategory(prefsMixedOriginAndPattern); | 604 setupCategory(settings.ALL_SITES, '', prefsMixedOriginAndPattern); |
| 552 | 605 |
| 553 return browserProxy.whenCalled('getExceptionList').then( | 606 return browserProxy.whenCalled('getExceptionList').then( |
| 554 function(contentType) { | 607 function(contentType) { |
| 555 // Use resolver to ensure asserts bubble up to the framework with | 608 // Use resolver to ensure asserts bubble up to the framework with |
| 556 // meaningful errors. | 609 // meaningful errors. |
| 557 var resolver = new PromiseResolver(); | 610 var resolver = new PromiseResolver(); |
| 558 testElement.async(resolver.resolve); | 611 testElement.async(resolver.resolve); |
| 559 return resolver.promise.then(function() { | 612 return resolver.promise.then(function() { |
| 560 // All Sites calls getExceptionList for all categories, starting | 613 // All Sites calls getExceptionList for all categories, starting |
| 561 // with Cookies. | 614 // with Cookies. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 582 MockInteractions.tap(clickable); | 635 MockInteractions.tap(clickable); |
| 583 assertEquals( | 636 assertEquals( |
| 584 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, | 637 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, |
| 585 testElement.selectedSite.originForDisplay); | 638 testElement.selectedSite.originForDisplay); |
| 586 }); | 639 }); |
| 587 }); | 640 }); |
| 588 }); | 641 }); |
| 589 | 642 |
| 590 test('Mixed schemes (present and absent)', function() { | 643 test('Mixed schemes (present and absent)', function() { |
| 591 // Prefs: One item with scheme and one without. | 644 // Prefs: One item with scheme and one without. |
| 592 setupLocationCategory(settings.PermissionValues.ALLOW, | 645 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 593 prefsMixedSchemes); | 646 settings.PermissionValues.ALLOW, prefsMixedSchemes); |
| 594 return browserProxy.whenCalled('getExceptionList').then( | 647 return browserProxy.whenCalled('getExceptionList').then( |
| 595 function(contentType) { | 648 function(contentType) { |
| 596 // No further checks needed. If this fails, it will hang the test. | 649 // No further checks needed. If this fails, it will hang the test. |
| 597 }); | 650 }); |
| 598 }); | 651 }); |
| 599 }); | 652 }); |
| 600 } | 653 } |
| 601 return { | 654 return { |
| 602 registerTests: registerTests, | 655 registerTests: registerTests, |
| 603 }; | 656 }; |
| 604 }); | 657 }); |
| OLD | NEW |