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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 */ | 357 */ |
| 358 function assertMenu(items) { | 358 function assertMenu(items) { |
| 359 var menuItems = getMenuItems(); | 359 var menuItems = getMenuItems(); |
| 360 assertEquals(items.length, menuItems.length); | 360 assertEquals(items.length, menuItems.length); |
| 361 for (var i = 0; i < items.length; i++) | 361 for (var i = 0; i < items.length; i++) |
| 362 assertEquals(items[i], menuItems[i].textContent.trim()); | 362 assertEquals(items[i], menuItems[i].textContent.trim()); |
| 363 } | 363 } |
| 364 | 364 |
| 365 /** | 365 /** |
| 366 * Configures the test element for a particular category. | 366 * Configures the test element for a particular category. |
| 367 * @param {settings.ContentSettingsTypes} category The category to setup. | 367 * @param {settings.ContentSettingsTypes} category The category to set up. |
| 368 * @param {settings.PermissionValues} subtype Type of list to use. | 368 * @param {settings.PermissionValues} subtype Type of list to use. |
| 369 * @param {Array<dictionary>} prefs The prefs to use. | 369 * @param {Array<dictionary>} prefs The prefs to use. |
| 370 */ | 370 */ |
| 371 function setupCategory(category, subtype, prefs) { | 371 function setUpCategory(category, subtype, prefs) { |
| 372 browserProxy.setPrefs(prefs); | 372 browserProxy.setPrefs(prefs); |
| 373 if (category == settings.ALL_SITES) { | 373 if (category == settings.ALL_SITES) { |
| 374 testElement.categorySubtype = settings.INVALID_CATEGORY_SUBTYPE; | 374 testElement.categorySubtype = settings.INVALID_CATEGORY_SUBTYPE; |
| 375 testElement.allSites = true; | 375 testElement.allSites = true; |
| 376 } else { | 376 } else { |
| 377 testElement.categorySubtype = subtype; | 377 testElement.categorySubtype = subtype; |
| 378 testElement.allSites = false; | 378 testElement.allSites = false; |
| 379 } | 379 } |
| 380 // Some route is needed, but the actual route doesn't matter. | 380 // Some route is needed, but the actual route doesn't matter. |
| 381 testElement.currentRoute = { | 381 testElement.currentRoute = { |
| 382 page: 'dummy', | 382 page: 'dummy', |
| 383 section: 'privacy', | 383 section: 'privacy', |
| 384 subpage: ['site-settings', 'site-settings-category-location'], | 384 subpage: ['site-settings', 'site-settings-category-location'], |
| 385 }; | 385 }; |
| 386 testElement.category = category; | 386 testElement.category = category; |
| 387 } | 387 } |
| 388 | 388 |
| 389 test('getExceptionList API used', function() { | 389 test('getExceptionList API used', function() { |
| 390 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 390 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 391 settings.PermissionValues.ALLOW, prefsEmpty); | 391 settings.PermissionValues.ALLOW, prefsEmpty); |
| 392 return browserProxy.whenCalled('getExceptionList').then( | 392 return browserProxy.whenCalled('getExceptionList').then( |
| 393 function(contentType) { | 393 function(contentType) { |
| 394 assertEquals( | 394 assertEquals( |
| 395 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 395 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 396 }); | 396 }); |
| 397 }); | 397 }); |
| 398 | 398 |
| 399 test('Empty list', function() { | 399 test('Empty list', function() { |
| 400 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 400 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 401 settings.PermissionValues.ALLOW, prefsEmpty); | 401 settings.PermissionValues.ALLOW, prefsEmpty); |
| 402 return browserProxy.whenCalled('getExceptionList').then( | 402 return browserProxy.whenCalled('getExceptionList').then( |
| 403 function(contentType) { | 403 function(contentType) { |
| 404 assertEquals( | 404 assertEquals( |
| 405 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 405 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 406 | 406 |
| 407 assertEquals(0, testElement.sites.length); | 407 assertEquals(0, testElement.sites.length); |
| 408 | 408 |
| 409 assertEquals( | 409 assertEquals( |
| 410 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 410 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 411 | 411 |
| 412 assertFalse(testElement.$.category.hidden); | 412 assertFalse(testElement.$.category.hidden); |
| 413 browserProxy.resetResolver('getExceptionList'); | 413 browserProxy.resetResolver('getExceptionList'); |
| 414 testElement.categoryEnabled = false; | 414 testElement.categoryEnabled = false; |
| 415 return browserProxy.whenCalled('getExceptionList'); | 415 return browserProxy.whenCalled('getExceptionList'); |
| 416 }).then(function(contentType) { | 416 }).then(function(contentType) { |
| 417 assertFalse(testElement.$.category.hidden); | 417 assertFalse(testElement.$.category.hidden); |
| 418 }); | 418 }); |
| 419 }); | 419 }); |
| 420 | 420 |
| 421 test('initial ALLOW state is correct', function() { | 421 test('initial ALLOW state is correct', function() { |
| 422 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 422 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 423 settings.PermissionValues.ALLOW, prefs); | 423 settings.PermissionValues.ALLOW, prefs); |
| 424 return browserProxy.whenCalled('getExceptionList').then( | 424 return browserProxy.whenCalled('getExceptionList').then( |
| 425 function(contentType) { | 425 function(contentType) { |
| 426 assertEquals( | 426 assertEquals( |
| 427 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 427 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 428 | 428 |
| 429 assertEquals(2, testElement.sites.length); | 429 assertEquals(2, testElement.sites.length); |
| 430 assertEquals(prefs.exceptions.geolocation[1].origin, | 430 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 431 testElement.sites[0].origin); | 431 testElement.sites[0].origin); |
| 432 assertEquals( | 432 assertEquals( |
| 433 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 433 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 434 Polymer.dom.flush(); // Populates action menu. | 434 Polymer.dom.flush(); // Populates action menu. |
| 435 openActionMenu(0); | 435 openActionMenu(0); |
| 436 assertMenu(['Block', 'Remove'], testElement); | 436 assertMenu(['Block', 'Remove'], testElement); |
| 437 | 437 |
| 438 // Site list should show, no matter what category default is set | 438 // Site list should show, no matter what category default is set |
| 439 // to. | 439 // to. |
| 440 assertFalse(testElement.$.category.hidden); | 440 assertFalse(testElement.$.category.hidden); |
| 441 browserProxy.resetResolver('getExceptionList'); | 441 browserProxy.resetResolver('getExceptionList'); |
| 442 testElement.categoryEnabled = false; | 442 testElement.categoryEnabled = false; |
| 443 return browserProxy.whenCalled('getExceptionList'); | 443 return browserProxy.whenCalled('getExceptionList'); |
| 444 }).then(function(contentType) { | 444 }).then(function(contentType) { |
| 445 assertFalse(testElement.$.category.hidden); | 445 assertFalse(testElement.$.category.hidden); |
| 446 }); | 446 }); |
| 447 }); | 447 }); |
| 448 | 448 |
| 449 test('initial BLOCK state is correct', function() { | 449 test('initial BLOCK state is correct', function() { |
| 450 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 450 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 451 settings.PermissionValues.BLOCK, prefs); | 451 settings.PermissionValues.BLOCK, prefs); |
| 452 return browserProxy.whenCalled('getExceptionList').then( | 452 return browserProxy.whenCalled('getExceptionList').then( |
| 453 function(contentType) { | 453 function(contentType) { |
| 454 assertEquals( | 454 assertEquals( |
| 455 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 455 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 456 | 456 |
| 457 assertEquals(2, testElement.sites.length); | 457 assertEquals(2, testElement.sites.length); |
| 458 assertEquals(prefs.exceptions.geolocation[3].origin, | 458 assertEquals(prefs.exceptions.geolocation[3].origin, |
| 459 testElement.sites[0].origin); | 459 testElement.sites[0].origin); |
| 460 | 460 |
| 461 assertEquals( | 461 assertEquals( |
| 462 settings.PermissionValues.BLOCK, testElement.categorySubtype); | 462 settings.PermissionValues.BLOCK, testElement.categorySubtype); |
| 463 Polymer.dom.flush(); // Populates action menu. | 463 Polymer.dom.flush(); // Populates action menu. |
| 464 openActionMenu(0); | 464 openActionMenu(0); |
| 465 assertMenu(['Allow', 'Remove'], testElement); | 465 assertMenu(['Allow', 'Remove'], testElement); |
| 466 | 466 |
| 467 // Site list should only show when category default is enabled. | 467 // Site list should show regardless of whether category the |
| 468 // default is enabled. | |
|
dpapad
2016/11/07 21:59:35
Seems that there is an extra "the", not sure.
dschuyler
2016/11/07 23:54:04
Done.
| |
| 468 assertFalse(testElement.$.category.hidden); | 469 assertFalse(testElement.$.category.hidden); |
| 469 browserProxy.resetResolver('getExceptionList'); | 470 browserProxy.resetResolver('getExceptionList'); |
| 470 testElement.categoryEnabled = false; | 471 testElement.categoryEnabled = false; |
| 471 return browserProxy.whenCalled('getExceptionList'); | 472 return browserProxy.whenCalled('getExceptionList'); |
| 472 }).then(function(contentType) { | 473 }).then(function(contentType) { |
| 473 assertTrue(testElement.$.category.hidden); | 474 assertFalse(testElement.$.category.hidden); |
| 474 }); | 475 }); |
| 475 }); | 476 }); |
| 476 | 477 |
| 477 test('initial SESSION ONLY state is correct', function() { | 478 test('initial SESSION ONLY state is correct', function() { |
| 478 setupCategory(settings.ContentSettingsTypes.COOKIES, | 479 setUpCategory(settings.ContentSettingsTypes.COOKIES, |
| 479 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); | 480 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); |
| 480 return browserProxy.whenCalled('getExceptionList').then( | 481 return browserProxy.whenCalled('getExceptionList').then( |
| 481 function(contentType) { | 482 function(contentType) { |
| 482 assertEquals( | 483 assertEquals( |
| 483 settings.ContentSettingsTypes.COOKIES, contentType); | 484 settings.ContentSettingsTypes.COOKIES, contentType); |
| 484 | 485 |
| 485 assertEquals(1, testElement.sites.length); | 486 assertEquals(1, testElement.sites.length); |
| 486 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, | 487 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, |
| 487 testElement.sites[0].origin); | 488 testElement.sites[0].origin); |
| 488 | 489 |
| 489 assertEquals(settings.PermissionValues.SESSION_ONLY, | 490 assertEquals(settings.PermissionValues.SESSION_ONLY, |
| 490 testElement.categorySubtype); | 491 testElement.categorySubtype); |
| 491 Polymer.dom.flush(); // Populates action menu. | 492 Polymer.dom.flush(); // Populates action menu. |
| 492 openActionMenu(0); | 493 openActionMenu(0); |
| 493 assertMenu(['Allow', 'Block', 'Remove'], testElement); | 494 assertMenu(['Allow', 'Block', 'Remove'], testElement); |
| 494 | 495 |
| 495 // Site list should show, no matter what category default is set | 496 // Site list should show, no matter what category default is set |
| 496 // to. | 497 // to. |
| 497 assertFalse(testElement.$.category.hidden); | 498 assertFalse(testElement.$.category.hidden); |
| 498 browserProxy.resetResolver('getExceptionList'); | 499 browserProxy.resetResolver('getExceptionList'); |
| 499 testElement.categoryEnabled = false; | 500 testElement.categoryEnabled = false; |
| 500 return browserProxy.whenCalled('getExceptionList'); | 501 return browserProxy.whenCalled('getExceptionList'); |
| 501 }).then(function(contentType) { | 502 }).then(function(contentType) { |
| 502 assertFalse(testElement.$.category.hidden); | 503 assertFalse(testElement.$.category.hidden); |
| 503 }); | 504 }); |
| 504 }); | 505 }); |
| 505 | 506 |
| 506 test('initial INCOGNITO BLOCK state is correct', function() { | 507 test('initial INCOGNITO BLOCK state is correct', function() { |
| 507 setupCategory(settings.ContentSettingsTypes.COOKIES, | 508 setUpCategory(settings.ContentSettingsTypes.COOKIES, |
| 508 settings.PermissionValues.BLOCK, prefsIncognito); | 509 settings.PermissionValues.BLOCK, prefsIncognito); |
| 509 return browserProxy.whenCalled('getExceptionList').then( | 510 return browserProxy.whenCalled('getExceptionList').then( |
| 510 function(contentType) { | 511 function(contentType) { |
| 511 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType); | 512 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType); |
| 512 | 513 |
| 513 assertEquals(1, testElement.sites.length); | 514 assertEquals(1, testElement.sites.length); |
| 514 assertEquals(prefsIncognito.exceptions.cookies[0].origin, | 515 assertEquals(prefsIncognito.exceptions.cookies[0].origin, |
| 515 testElement.sites[0].origin); | 516 testElement.sites[0].origin); |
| 516 | 517 |
| 517 assertEquals(settings.PermissionValues.BLOCK, | 518 assertEquals(settings.PermissionValues.BLOCK, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 529 'resetCategoryPermissionForOrigin'); | 530 'resetCategoryPermissionForOrigin'); |
| 530 }).then(function(args) { | 531 }).then(function(args) { |
| 531 assertEquals('http://foo.com', args[0]); | 532 assertEquals('http://foo.com', args[0]); |
| 532 assertEquals('http://foo.com', args[1]); | 533 assertEquals('http://foo.com', args[1]); |
| 533 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); | 534 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); |
| 534 assertFalse(args[3]); // Incognito. | 535 assertFalse(args[3]); // Incognito. |
| 535 }); | 536 }); |
| 536 }); | 537 }); |
| 537 | 538 |
| 538 test('initial INCOGNITO ALLOW state is correct', function() { | 539 test('initial INCOGNITO ALLOW state is correct', function() { |
| 539 setupCategory(settings.ContentSettingsTypes.COOKIES, | 540 setUpCategory(settings.ContentSettingsTypes.COOKIES, |
| 540 settings.PermissionValues.ALLOW, prefsIncognito); | 541 settings.PermissionValues.ALLOW, prefsIncognito); |
| 541 return browserProxy.whenCalled('getExceptionList').then( | 542 return browserProxy.whenCalled('getExceptionList').then( |
| 542 function(contentType) { | 543 function(contentType) { |
| 543 assertEquals( | 544 assertEquals( |
| 544 settings.ContentSettingsTypes.COOKIES, contentType); | 545 settings.ContentSettingsTypes.COOKIES, contentType); |
| 545 | 546 |
| 546 assertEquals(2, testElement.sites.length); | 547 assertEquals(2, testElement.sites.length); |
| 547 assertEquals(prefsIncognito.exceptions.cookies[2].origin, | 548 assertEquals(prefsIncognito.exceptions.cookies[2].origin, |
| 548 testElement.sites[0].origin); | 549 testElement.sites[0].origin); |
| 549 assertEquals(prefsIncognito.exceptions.cookies[1].origin, | 550 assertEquals(prefsIncognito.exceptions.cookies[1].origin, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 566 'resetCategoryPermissionForOrigin'); | 567 'resetCategoryPermissionForOrigin'); |
| 567 }).then(function(args) { | 568 }).then(function(args) { |
| 568 assertEquals('http://foo.com', args[0]); | 569 assertEquals('http://foo.com', args[0]); |
| 569 assertEquals('http://foo.com', args[1]); | 570 assertEquals('http://foo.com', args[1]); |
| 570 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); | 571 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); |
| 571 assertTrue(args[3]); // Incognito. | 572 assertTrue(args[3]); // Incognito. |
| 572 }); | 573 }); |
| 573 }); | 574 }); |
| 574 | 575 |
| 575 test('list items shown and clickable when data is present', function() { | 576 test('list items shown and clickable when data is present', function() { |
| 576 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 577 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 577 settings.PermissionValues.ALLOW, prefs); | 578 settings.PermissionValues.ALLOW, prefs); |
| 578 return browserProxy.whenCalled('getExceptionList').then( | 579 return browserProxy.whenCalled('getExceptionList').then( |
| 579 function(contentType) { | 580 function(contentType) { |
| 580 testElement.enableSiteSettings_ = true; | 581 testElement.enableSiteSettings_ = true; |
| 581 assertEquals( | 582 assertEquals( |
| 582 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 583 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 583 | 584 |
| 584 // Required for firstItem to be found below. | 585 // Required for firstItem to be found below. |
| 585 Polymer.dom.flush(); | 586 Polymer.dom.flush(); |
| 586 | 587 |
| 587 // Validate that the sites gets populated from pre-canned prefs. | 588 // Validate that the sites gets populated from pre-canned prefs. |
| 588 assertEquals(2, testElement.sites.length); | 589 assertEquals(2, testElement.sites.length); |
| 589 assertEquals(prefs.exceptions.geolocation[1].origin, | 590 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 590 testElement.sites[0].origin); | 591 testElement.sites[0].origin); |
| 591 assertEquals(undefined, testElement.selectedOrigin); | 592 assertEquals(undefined, testElement.selectedOrigin); |
| 592 | 593 |
| 593 // Validate that the sites are shown in UI and can be selected. | 594 // Validate that the sites are shown in UI and can be selected. |
| 594 var firstItem = testElement.$.listContainer.children[0]; | 595 var firstItem = testElement.$.listContainer.children[0]; |
| 595 var clickable = firstItem.querySelector('.middle'); | 596 var clickable = firstItem.querySelector('.middle'); |
| 596 assertNotEquals(undefined, clickable); | 597 assertNotEquals(undefined, clickable); |
| 597 MockInteractions.tap(clickable); | 598 MockInteractions.tap(clickable); |
| 598 assertEquals(prefs.exceptions.geolocation[1].origin, | 599 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 599 testElement.selectedSite.origin); | 600 testElement.selectedSite.origin); |
| 600 }); | 601 }); |
| 601 }); | 602 }); |
| 602 | 603 |
| 603 test('Block list open when Allow list is empty', function() { | 604 test('Block list open when Allow list is empty', function() { |
| 604 // Prefs: One item in Block list, nothing in Allow list. | 605 // Prefs: One item in Block list, nothing in Allow list. |
| 605 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 606 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 606 settings.PermissionValues.BLOCK, prefsOneDisabled); | 607 settings.PermissionValues.BLOCK, prefsOneDisabled); |
| 607 return browserProxy.whenCalled('getExceptionList').then( | 608 return browserProxy.whenCalled('getExceptionList').then( |
| 608 function(contentType) { | 609 function(contentType) { |
| 609 assertEquals( | 610 assertEquals( |
| 610 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 611 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 611 assertFalse(testElement.$.category.hidden); | 612 assertFalse(testElement.$.category.hidden); |
| 612 }).then(function() { | 613 }).then(function() { |
| 613 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 614 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 614 }); | 615 }); |
| 615 }); | 616 }); |
| 616 | 617 |
| 617 test('Block list closed when Allow list is not empty', function() { | 618 test('Block list closed when Allow list is not empty', function() { |
| 618 // Prefs: Items in both Block and Allow list. | 619 // Prefs: Items in both Block and Allow list. |
| 619 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 620 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 620 settings.PermissionValues.BLOCK, prefs); | 621 settings.PermissionValues.BLOCK, prefs); |
| 621 return browserProxy.whenCalled('getExceptionList').then( | 622 return browserProxy.whenCalled('getExceptionList').then( |
| 622 function(contentType) { | 623 function(contentType) { |
| 623 assertEquals( | 624 assertEquals( |
| 624 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 625 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 625 assertFalse(testElement.$.category.hidden); | 626 assertFalse(testElement.$.category.hidden); |
| 626 assertEquals(0, testElement.$.listContainer.offsetHeight); | 627 assertEquals(0, testElement.$.listContainer.offsetHeight); |
| 627 }); | 628 }); |
| 628 }); | 629 }); |
| 629 | 630 |
| 630 test('Allow list is always open (Block list empty)', function() { | 631 test('Allow list is always open (Block list empty)', function() { |
| 631 // Prefs: One item in Allow list, nothing in Block list. | 632 // Prefs: One item in Allow list, nothing in Block list. |
| 632 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 633 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 633 settings.PermissionValues.ALLOW, prefsOneEnabled); | 634 settings.PermissionValues.ALLOW, prefsOneEnabled); |
| 634 return browserProxy.whenCalled('getExceptionList').then( | 635 return browserProxy.whenCalled('getExceptionList').then( |
| 635 function(contentType) { | 636 function(contentType) { |
| 636 assertEquals( | 637 assertEquals( |
| 637 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 638 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 638 | 639 |
| 639 assertFalse(testElement.$.category.hidden); | 640 assertFalse(testElement.$.category.hidden); |
| 640 }).then(function() { | 641 }).then(function() { |
| 641 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 642 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 642 }); | 643 }); |
| 643 }); | 644 }); |
| 644 | 645 |
| 645 test('Allow list is always open (Block list non-empty)', function() { | 646 test('Allow list is always open (Block list non-empty)', function() { |
| 646 // Prefs: Items in both Block and Allow list. | 647 // Prefs: Items in both Block and Allow list. |
| 647 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 648 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 648 settings.PermissionValues.ALLOW, prefs); | 649 settings.PermissionValues.ALLOW, prefs); |
| 649 return browserProxy.whenCalled('getExceptionList').then( | 650 return browserProxy.whenCalled('getExceptionList').then( |
| 650 function(contentType) { | 651 function(contentType) { |
| 651 assertEquals( | 652 assertEquals( |
| 652 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 653 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 653 assertFalse(testElement.$.category.hidden); | 654 assertFalse(testElement.$.category.hidden); |
| 654 }).then(function() { | 655 }).then(function() { |
| 655 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 656 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 656 }); | 657 }); |
| 657 }); | 658 }); |
| 658 | 659 |
| 659 test('Block list not hidden when empty', function() { | 660 test('Block list not hidden when empty', function() { |
| 660 // Prefs: One item in Allow list, nothing in Block list. | 661 // Prefs: One item in Allow list, nothing in Block list. |
| 661 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 662 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 662 settings.PermissionValues.BLOCK, prefsOneEnabled); | 663 settings.PermissionValues.BLOCK, prefsOneEnabled); |
| 663 return browserProxy.whenCalled('getExceptionList').then( | 664 return browserProxy.whenCalled('getExceptionList').then( |
| 664 function(contentType) { | 665 function(contentType) { |
| 665 assertEquals( | 666 assertEquals( |
| 666 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 667 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 667 assertFalse(testElement.$.category.hidden); | 668 assertFalse(testElement.$.category.hidden); |
| 668 }); | 669 }); |
| 669 }); | 670 }); |
| 670 | 671 |
| 671 test('Allow list not hidden when empty', function() { | 672 test('Allow list not hidden when empty', function() { |
| 672 // Prefs: One item in Block list, nothing in Allow list. | 673 // Prefs: One item in Block list, nothing in Allow list. |
| 673 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 674 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 674 settings.PermissionValues.ALLOW, prefsOneDisabled); | 675 settings.PermissionValues.ALLOW, prefsOneDisabled); |
| 675 return browserProxy.whenCalled('getExceptionList').then( | 676 return browserProxy.whenCalled('getExceptionList').then( |
| 676 function(contentType) { | 677 function(contentType) { |
| 677 assertEquals( | 678 assertEquals( |
| 678 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 679 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 679 assertFalse(testElement.$.category.hidden); | 680 assertFalse(testElement.$.category.hidden); |
| 680 }); | 681 }); |
| 681 }); | 682 }); |
| 682 | 683 |
| 683 test('All sites category', function() { | 684 test('All sites category', function() { |
| 684 // Prefs: Multiple and overlapping sites. | 685 // Prefs: Multiple and overlapping sites. |
| 685 setupCategory(settings.ALL_SITES, '', prefsVarious); | 686 setUpCategory(settings.ALL_SITES, '', prefsVarious); |
| 686 | 687 |
| 687 return browserProxy.whenCalled('getExceptionList').then( | 688 return browserProxy.whenCalled('getExceptionList').then( |
| 688 function(contentType) { | 689 function(contentType) { |
| 689 // Use resolver to ensure asserts bubble up to the framework with | 690 // Use resolver to ensure asserts bubble up to the framework with |
| 690 // meaningful errors. | 691 // meaningful errors. |
| 691 var resolver = new PromiseResolver(); | 692 var resolver = new PromiseResolver(); |
| 692 testElement.async(resolver.resolve); | 693 testElement.async(resolver.resolve); |
| 693 return resolver.promise.then(function() { | 694 return resolver.promise.then(function() { |
| 694 testElement.enableSiteSettings_ = true; | 695 testElement.enableSiteSettings_ = true; |
| 695 // All Sites calls getExceptionList for all categories, starting | 696 // All Sites calls getExceptionList for all categories, starting |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 719 assertNotEquals(undefined, clickable); | 720 assertNotEquals(undefined, clickable); |
| 720 MockInteractions.tap(clickable); | 721 MockInteractions.tap(clickable); |
| 721 assertEquals(prefsVarious.exceptions.geolocation[0].origin, | 722 assertEquals(prefsVarious.exceptions.geolocation[0].origin, |
| 722 testElement.selectedSite.origin); | 723 testElement.selectedSite.origin); |
| 723 }); | 724 }); |
| 724 }); | 725 }); |
| 725 }); | 726 }); |
| 726 | 727 |
| 727 test('All sites mixed pattern and origin', function() { | 728 test('All sites mixed pattern and origin', function() { |
| 728 // Prefs: One site, represented as origin and pattern. | 729 // Prefs: One site, represented as origin and pattern. |
| 729 setupCategory(settings.ALL_SITES, '', prefsMixedOriginAndPattern); | 730 setUpCategory(settings.ALL_SITES, '', prefsMixedOriginAndPattern); |
| 730 | 731 |
| 731 return browserProxy.whenCalled('getExceptionList').then( | 732 return browserProxy.whenCalled('getExceptionList').then( |
| 732 function(contentType) { | 733 function(contentType) { |
| 733 // Use resolver to ensure asserts bubble up to the framework with | 734 // Use resolver to ensure asserts bubble up to the framework with |
| 734 // meaningful errors. | 735 // meaningful errors. |
| 735 var resolver = new PromiseResolver(); | 736 var resolver = new PromiseResolver(); |
| 736 testElement.async(resolver.resolve); | 737 testElement.async(resolver.resolve); |
| 737 return resolver.promise.then(function() { | 738 return resolver.promise.then(function() { |
| 738 testElement.enableSiteSettings_ = true; | 739 testElement.enableSiteSettings_ = true; |
| 739 // All Sites calls getExceptionList for all categories, starting | 740 // All Sites calls getExceptionList for all categories, starting |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 761 MockInteractions.tap(clickable); | 762 MockInteractions.tap(clickable); |
| 762 assertEquals( | 763 assertEquals( |
| 763 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, | 764 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, |
| 764 testElement.selectedSite.originForDisplay); | 765 testElement.selectedSite.originForDisplay); |
| 765 }); | 766 }); |
| 766 }); | 767 }); |
| 767 }); | 768 }); |
| 768 | 769 |
| 769 test('Mixed schemes (present and absent)', function() { | 770 test('Mixed schemes (present and absent)', function() { |
| 770 // Prefs: One item with scheme and one without. | 771 // Prefs: One item with scheme and one without. |
| 771 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 772 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 772 settings.PermissionValues.ALLOW, prefsMixedSchemes); | 773 settings.PermissionValues.ALLOW, prefsMixedSchemes); |
| 773 return browserProxy.whenCalled('getExceptionList').then( | 774 return browserProxy.whenCalled('getExceptionList').then( |
| 774 function(contentType) { | 775 function(contentType) { |
| 775 // No further checks needed. If this fails, it will hang the test. | 776 // No further checks needed. If this fails, it will hang the test. |
| 776 }); | 777 }); |
| 777 }); | 778 }); |
| 778 | 779 |
| 779 test('Select menu item', function() { | 780 test('Select menu item', function() { |
| 780 // Test for error: "Cannot read property 'origin' of undefined". | 781 // Test for error: "Cannot read property 'origin' of undefined". |
| 781 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 782 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 782 settings.PermissionValues.ALLOW, prefs); | 783 settings.PermissionValues.ALLOW, prefs); |
| 783 return browserProxy.whenCalled('getExceptionList').then(function( | 784 return browserProxy.whenCalled('getExceptionList').then(function( |
| 784 contentType) { | 785 contentType) { |
| 785 Polymer.dom.flush(); | 786 Polymer.dom.flush(); |
| 786 openActionMenu(0); | 787 openActionMenu(0); |
| 787 var menuItems = getMenuItems(); | 788 var menuItems = getMenuItems(); |
| 788 assertTrue(!!menuItems); | 789 assertTrue(!!menuItems); |
| 789 MockInteractions.tap(menuItems[0]); | 790 MockInteractions.tap(menuItems[0]); |
| 790 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); | 791 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); |
| 791 }); | 792 }); |
| 792 }); | 793 }); |
| 793 | 794 |
| 794 test('Chrome Extension scheme', function() { | 795 test('Chrome Extension scheme', function() { |
| 795 setupCategory(settings.ContentSettingsTypes.JAVASCRIPT, | 796 setUpCategory(settings.ContentSettingsTypes.JAVASCRIPT, |
| 796 settings.PermissionValues.BLOCK, prefsChromeExtension); | 797 settings.PermissionValues.BLOCK, prefsChromeExtension); |
| 797 return browserProxy.whenCalled('getExceptionList').then(function( | 798 return browserProxy.whenCalled('getExceptionList').then(function( |
| 798 contentType) { | 799 contentType) { |
| 799 Polymer.dom.flush(); | 800 Polymer.dom.flush(); |
| 800 openActionMenu(0); | 801 openActionMenu(0); |
| 801 assertMenu(['Allow', 'Remove'], testElement); | 802 assertMenu(['Allow', 'Remove'], testElement); |
| 802 | 803 |
| 803 var menuItems = getMenuItems(); | 804 var menuItems = getMenuItems(); |
| 804 assertTrue(!!menuItems); | 805 assertTrue(!!menuItems); |
| 805 MockInteractions.tap(menuItems[0]); // Action: Allow. | 806 MockInteractions.tap(menuItems[0]); // Action: Allow. |
| 806 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); | 807 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); |
| 807 }).then(function(args) { | 808 }).then(function(args) { |
| 808 assertEquals('chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/', | 809 assertEquals('chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/', |
| 809 args[0]); | 810 args[0]); |
| 810 assertEquals('', args[1]); | 811 assertEquals('', args[1]); |
| 811 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); | 812 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); |
| 812 assertEquals('allow', args[3]); | 813 assertEquals('allow', args[3]); |
| 813 }); | 814 }); |
| 814 }); | 815 }); |
| 815 }); | 816 }); |
| 816 } | 817 } |
| 817 return { | 818 return { |
| 818 registerTests: registerTests, | 819 registerTests: registerTests, |
| 819 }; | 820 }; |
| 820 }); | 821 }); |
| OLD | NEW |