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

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

Issue 2429973003: [MD settings] content settings add site button; layout fixes (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 }); 593 });
594 594
595 test('Block list open when Allow list is empty', function() { 595 test('Block list open when Allow list is empty', function() {
596 // Prefs: One item in Block list, nothing in Allow list. 596 // Prefs: One item in Block list, nothing in Allow list.
597 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 597 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
598 settings.PermissionValues.BLOCK, prefsOneDisabled); 598 settings.PermissionValues.BLOCK, prefsOneDisabled);
599 return browserProxy.whenCalled('getExceptionList').then( 599 return browserProxy.whenCalled('getExceptionList').then(
600 function(contentType) { 600 function(contentType) {
601 assertEquals( 601 assertEquals(
602 settings.ContentSettingsTypes.GEOLOCATION, contentType); 602 settings.ContentSettingsTypes.GEOLOCATION, contentType);
603
604 assertFalse(testElement.$.category.hidden); 603 assertFalse(testElement.$.category.hidden);
605 assertTrue(testElement.$.category.opened);
606 }).then(function() { 604 }).then(function() {
607 assertNotEquals(0, testElement.$.listContainer.offsetHeight); 605 assertNotEquals(0, testElement.$.listContainer.offsetHeight);
608 }); 606 });
609 }); 607 });
610 608
611 test('Block list closed when Allow list is not empty', function() { 609 test('Block list closed when Allow list is not empty', function() {
612 // Prefs: Items in both Block and Allow list. 610 // Prefs: Items in both Block and Allow list.
613 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 611 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
614 settings.PermissionValues.BLOCK, prefs); 612 settings.PermissionValues.BLOCK, prefs);
615 return browserProxy.whenCalled('getExceptionList').then( 613 return browserProxy.whenCalled('getExceptionList').then(
616 function(contentType) { 614 function(contentType) {
617 assertEquals( 615 assertEquals(
618 settings.ContentSettingsTypes.GEOLOCATION, contentType); 616 settings.ContentSettingsTypes.GEOLOCATION, contentType);
619
620 assertFalse(testElement.$.category.hidden); 617 assertFalse(testElement.$.category.hidden);
621 assertFalse(testElement.$.category.opened);
622 assertEquals(0, testElement.$.listContainer.offsetHeight); 618 assertEquals(0, testElement.$.listContainer.offsetHeight);
623 }); 619 });
624 }); 620 });
625 621
626 test('Allow list is always open (Block list empty)', function() { 622 test('Allow list is always open (Block list empty)', function() {
627 // Prefs: One item in Allow list, nothing in Block list. 623 // Prefs: One item in Allow list, nothing in Block list.
628 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 624 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
629 settings.PermissionValues.ALLOW, prefsOneEnabled); 625 settings.PermissionValues.ALLOW, prefsOneEnabled);
630 return browserProxy.whenCalled('getExceptionList').then( 626 return browserProxy.whenCalled('getExceptionList').then(
631 function(contentType) { 627 function(contentType) {
632 assertEquals( 628 assertEquals(
633 settings.ContentSettingsTypes.GEOLOCATION, contentType); 629 settings.ContentSettingsTypes.GEOLOCATION, contentType);
634 630
635 assertFalse(testElement.$.category.hidden); 631 assertFalse(testElement.$.category.hidden);
636 assertTrue(testElement.$.category.opened);
637 }).then(function() { 632 }).then(function() {
638 assertNotEquals(0, testElement.$.listContainer.offsetHeight); 633 assertNotEquals(0, testElement.$.listContainer.offsetHeight);
639 }); 634 });
640 }); 635 });
641 636
642 test('Allow list is always open (Block list non-empty)', function() { 637 test('Allow list is always open (Block list non-empty)', function() {
643 // Prefs: Items in both Block and Allow list. 638 // Prefs: Items in both Block and Allow list.
644 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 639 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
645 settings.PermissionValues.ALLOW, prefs); 640 settings.PermissionValues.ALLOW, prefs);
646 return browserProxy.whenCalled('getExceptionList').then( 641 return browserProxy.whenCalled('getExceptionList').then(
647 function(contentType) { 642 function(contentType) {
648 assertEquals( 643 assertEquals(
649 settings.ContentSettingsTypes.GEOLOCATION, contentType); 644 settings.ContentSettingsTypes.GEOLOCATION, contentType);
650
651 assertFalse(testElement.$.category.hidden); 645 assertFalse(testElement.$.category.hidden);
652 assertTrue(testElement.$.category.opened);
653 }).then(function() { 646 }).then(function() {
654 assertNotEquals(0, testElement.$.listContainer.offsetHeight); 647 assertNotEquals(0, testElement.$.listContainer.offsetHeight);
655 }); 648 });
656 }); 649 });
657 650
658 test('Block list not hidden when empty', function() { 651 test('Block list not hidden when empty', function() {
659 // Prefs: One item in Allow list, nothing in Block list. 652 // Prefs: One item in Allow list, nothing in Block list.
660 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 653 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
661 settings.PermissionValues.BLOCK, prefsOneEnabled); 654 settings.PermissionValues.BLOCK, prefsOneEnabled);
662 return browserProxy.whenCalled('getExceptionList').then( 655 return browserProxy.whenCalled('getExceptionList').then(
663 function(contentType) { 656 function(contentType) {
664 assertEquals( 657 assertEquals(
665 settings.ContentSettingsTypes.GEOLOCATION, contentType); 658 settings.ContentSettingsTypes.GEOLOCATION, contentType);
666
667 assertFalse(testElement.$.category.hidden); 659 assertFalse(testElement.$.category.hidden);
668 }); 660 });
669 }); 661 });
670 662
671 test('Allow list not hidden when empty', function() { 663 test('Allow list not hidden when empty', function() {
672 // Prefs: One item in Block list, nothing in Allow list. 664 // Prefs: One item in Block list, nothing in Allow list.
673 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 665 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
674 settings.PermissionValues.ALLOW, prefsOneDisabled); 666 settings.PermissionValues.ALLOW, prefsOneDisabled);
675 return browserProxy.whenCalled('getExceptionList').then( 667 return browserProxy.whenCalled('getExceptionList').then(
676 function(contentType) { 668 function(contentType) {
677 assertEquals( 669 assertEquals(
678 settings.ContentSettingsTypes.GEOLOCATION, contentType); 670 settings.ContentSettingsTypes.GEOLOCATION, contentType);
679
680 assertFalse(testElement.$.category.hidden); 671 assertFalse(testElement.$.category.hidden);
681 }); 672 });
682 }); 673 });
683 674
684 test('All sites category', function() { 675 test('All sites category', function() {
685 // Prefs: Multiple and overlapping sites. 676 // Prefs: Multiple and overlapping sites.
686 setupCategory(settings.ALL_SITES, '', prefsVarious); 677 setupCategory(settings.ALL_SITES, '', prefsVarious);
687 678
688 return browserProxy.whenCalled('getExceptionList').then( 679 return browserProxy.whenCalled('getExceptionList').then(
689 function(contentType) { 680 function(contentType) {
690 // Use resolver to ensure asserts bubble up to the framework with 681 // Use resolver to ensure asserts bubble up to the framework with
691 // meaningful errors. 682 // meaningful errors.
692 var resolver = new PromiseResolver(); 683 var resolver = new PromiseResolver();
693 testElement.async(resolver.resolve); 684 testElement.async(resolver.resolve);
694 return resolver.promise.then(function() { 685 return resolver.promise.then(function() {
695 testElement.enableSiteSettings_ = true; 686 testElement.enableSiteSettings_ = true;
696 // All Sites calls getExceptionList for all categories, starting 687 // All Sites calls getExceptionList for all categories, starting
697 // with Cookies. 688 // with Cookies.
698 assertEquals( 689 assertEquals(
699 settings.ContentSettingsTypes.COOKIES, contentType); 690 settings.ContentSettingsTypes.COOKIES, contentType);
700 691
701 // Required for firstItem to be found below. 692 // Required for firstItem to be found below.
702 Polymer.dom.flush(); 693 Polymer.dom.flush();
703 694
704 assertTrue(testElement.$.category.opened);
705 assertFalse(testElement.$.category.hidden); 695 assertFalse(testElement.$.category.hidden);
706 // Validate that the sites gets populated from pre-canned prefs. 696 // Validate that the sites gets populated from pre-canned prefs.
707 assertEquals(3, testElement.sites.length, 697 assertEquals(3, testElement.sites.length,
708 'If this fails with 5 instead of the expected 3, then ' + 698 'If this fails with 5 instead of the expected 3, then ' +
709 'the de-duping of sites is not working for site_list'); 699 'the de-duping of sites is not working for site_list');
710 assertEquals(prefsVarious.exceptions.geolocation[1].origin, 700 assertEquals(prefsVarious.exceptions.geolocation[1].origin,
711 testElement.sites[0].origin); 701 testElement.sites[0].origin);
712 assertEquals(prefsVarious.exceptions.geolocation[0].origin, 702 assertEquals(prefsVarious.exceptions.geolocation[0].origin,
713 testElement.sites[1].origin); 703 testElement.sites[1].origin);
714 assertEquals(prefsVarious.exceptions.notifications[0].origin, 704 assertEquals(prefsVarious.exceptions.notifications[0].origin,
(...skipping 24 matching lines...) Expand all
739 return resolver.promise.then(function() { 729 return resolver.promise.then(function() {
740 testElement.enableSiteSettings_ = true; 730 testElement.enableSiteSettings_ = true;
741 // All Sites calls getExceptionList for all categories, starting 731 // All Sites calls getExceptionList for all categories, starting
742 // with Cookies. 732 // with Cookies.
743 assertEquals( 733 assertEquals(
744 settings.ContentSettingsTypes.COOKIES, contentType); 734 settings.ContentSettingsTypes.COOKIES, contentType);
745 735
746 // Required for firstItem to be found below. 736 // Required for firstItem to be found below.
747 Polymer.dom.flush(); 737 Polymer.dom.flush();
748 738
749 assertTrue(testElement.$.category.opened);
750 assertFalse(testElement.$.category.hidden); 739 assertFalse(testElement.$.category.hidden);
751 // Validate that the sites gets populated from pre-canned prefs. 740 // Validate that the sites gets populated from pre-canned prefs.
752 assertEquals(1, testElement.sites.length, 741 assertEquals(1, testElement.sites.length,
753 'If this fails with 2 instead of the expected 1, then ' + 742 'If this fails with 2 instead of the expected 1, then ' +
754 'the de-duping of sites is not working for site_list'); 743 'the de-duping of sites is not working for site_list');
755 assertEquals( 744 assertEquals(
756 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, 745 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin,
757 testElement.sites[0].originForDisplay); 746 testElement.sites[0].originForDisplay);
758 747
759 assertEquals(undefined, testElement.selectedOrigin); 748 assertEquals(undefined, testElement.selectedOrigin);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); 803 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]);
815 assertEquals('allow', args[3]); 804 assertEquals('allow', args[3]);
816 }); 805 });
817 }); 806 });
818 }); 807 });
819 } 808 }
820 return { 809 return {
821 registerTests: registerTests, 810 registerTests: registerTests,
822 }; 811 };
823 }); 812 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698