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

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

Issue 2768053004: [MD settings] change sites to private sites_
Patch Set: Created 3 years, 9 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/resources/settings/site_settings/site_list.js ('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 /** 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 }); 485 });
486 486
487 test('Empty list', function() { 487 test('Empty list', function() {
488 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, 488 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
489 settings.PermissionValues.ALLOW, prefsEmpty); 489 settings.PermissionValues.ALLOW, prefsEmpty);
490 return browserProxy.whenCalled('getExceptionList').then( 490 return browserProxy.whenCalled('getExceptionList').then(
491 function(contentType) { 491 function(contentType) {
492 assertEquals( 492 assertEquals(
493 settings.ContentSettingsTypes.GEOLOCATION, contentType); 493 settings.ContentSettingsTypes.GEOLOCATION, contentType);
494 494
495 assertEquals(0, testElement.sites.length); 495 assertEquals(0, testElement.sites_.length);
dpapad 2017/03/23 22:38:12 As I see it, making |sites| private, should be acc
496 496
497 assertEquals( 497 assertEquals(
498 settings.PermissionValues.ALLOW, testElement.categorySubtype); 498 settings.PermissionValues.ALLOW, testElement.categorySubtype);
499 499
500 assertFalse(testElement.$.category.hidden); 500 assertFalse(testElement.$.category.hidden);
501 }); 501 });
502 }); 502 });
503 503
504 test('initial ALLOW state is correct', function() { 504 test('initial ALLOW state is correct', function() {
505 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, 505 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
506 settings.PermissionValues.ALLOW, prefs); 506 settings.PermissionValues.ALLOW, prefs);
507 return browserProxy.whenCalled('getExceptionList').then( 507 return browserProxy.whenCalled('getExceptionList').then(
508 function(contentType) { 508 function(contentType) {
509 assertEquals( 509 assertEquals(
510 settings.ContentSettingsTypes.GEOLOCATION, contentType); 510 settings.ContentSettingsTypes.GEOLOCATION, contentType);
511 511
512 assertEquals(2, testElement.sites.length); 512 assertEquals(2, testElement.sites_.length);
513 assertEquals(prefs.exceptions.geolocation[0].origin, 513 assertEquals(prefs.exceptions.geolocation[0].origin,
514 testElement.sites[0].origin); 514 testElement.sites_[0].origin);
515 assertEquals(prefs.exceptions.geolocation[1].origin, 515 assertEquals(prefs.exceptions.geolocation[1].origin,
516 testElement.sites[1].origin); 516 testElement.sites_[1].origin);
517 assertEquals( 517 assertEquals(
518 settings.PermissionValues.ALLOW, testElement.categorySubtype); 518 settings.PermissionValues.ALLOW, testElement.categorySubtype);
519 Polymer.dom.flush(); // Populates action menu. 519 Polymer.dom.flush(); // Populates action menu.
520 openActionMenu(0); 520 openActionMenu(0);
521 assertMenu(['Block', 'Edit', 'Remove'], testElement); 521 assertMenu(['Block', 'Edit', 'Remove'], testElement);
522 522
523 assertFalse(testElement.$.category.hidden); 523 assertFalse(testElement.$.category.hidden);
524 }); 524 });
525 }); 525 });
526 526
(...skipping 20 matching lines...) Expand all
547 }); 547 });
548 548
549 test('exceptions are not reordered in non-ALL_SITES', function() { 549 test('exceptions are not reordered in non-ALL_SITES', function() {
550 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, 550 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
551 settings.PermissionValues.BLOCK, prefsMixedProvider); 551 settings.PermissionValues.BLOCK, prefsMixedProvider);
552 return browserProxy.whenCalled('getExceptionList').then( 552 return browserProxy.whenCalled('getExceptionList').then(
553 function(contentType) { 553 function(contentType) {
554 assertEquals( 554 assertEquals(
555 settings.ContentSettingsTypes.GEOLOCATION, contentType); 555 settings.ContentSettingsTypes.GEOLOCATION, contentType);
556 556
557 assertEquals(3, testElement.sites.length); 557 assertEquals(3, testElement.sites_.length);
558 for(var i = 0; i < 3; i++) { 558 for(var i = 0; i < 3; i++) {
559 assertEquals( 559 assertEquals(
560 prefsMixedProvider.exceptions.geolocation[0].origin, 560 prefsMixedProvider.exceptions.geolocation[0].origin,
561 testElement.sites[0].origin); 561 testElement.sites_[0].origin);
562 assertEquals( 562 assertEquals(
563 prefsMixedProvider.exceptions.geolocation[0].source, 563 prefsMixedProvider.exceptions.geolocation[0].source,
564 testElement.sites[0].source); 564 testElement.sites_[0].source);
565 } 565 }
566 }); 566 });
567 }); 567 });
568 568
569 test('initial BLOCK state is correct', function() { 569 test('initial BLOCK state is correct', function() {
570 var contentType = settings.ContentSettingsTypes.GEOLOCATION; 570 var contentType = settings.ContentSettingsTypes.GEOLOCATION;
571 var categorySubtype = settings.PermissionValues.BLOCK; 571 var categorySubtype = settings.PermissionValues.BLOCK;
572 setUpCategory(contentType, categorySubtype, prefs); 572 setUpCategory(contentType, categorySubtype, prefs);
573 return browserProxy.whenCalled('getExceptionList').then( 573 return browserProxy.whenCalled('getExceptionList').then(
574 function(actualContentType) { 574 function(actualContentType) {
575 assertEquals(contentType, actualContentType); 575 assertEquals(contentType, actualContentType);
576 assertEquals(categorySubtype, testElement.categorySubtype); 576 assertEquals(categorySubtype, testElement.categorySubtype);
577 577
578 assertEquals(2, testElement.sites.length); 578 assertEquals(2, testElement.sites_.length);
579 assertEquals( 579 assertEquals(
580 prefs.exceptions.geolocation[2].origin, 580 prefs.exceptions.geolocation[2].origin,
581 testElement.sites[0].origin); 581 testElement.sites_[0].origin);
582 assertEquals( 582 assertEquals(
583 prefs.exceptions.geolocation[3].origin, 583 prefs.exceptions.geolocation[3].origin,
584 testElement.sites[1].origin); 584 testElement.sites_[1].origin);
585 Polymer.dom.flush(); // Populates action menu. 585 Polymer.dom.flush(); // Populates action menu.
586 openActionMenu(0); 586 openActionMenu(0);
587 assertMenu(['Allow', 'Edit', 'Remove'], testElement); 587 assertMenu(['Allow', 'Edit', 'Remove'], testElement);
588 588
589 assertFalse(testElement.$.category.hidden); 589 assertFalse(testElement.$.category.hidden);
590 }); 590 });
591 }); 591 });
592 592
593 test('initial SESSION ONLY state is correct', function() { 593 test('initial SESSION ONLY state is correct', function() {
594 var contentType = settings.ContentSettingsTypes.COOKIES; 594 var contentType = settings.ContentSettingsTypes.COOKIES;
595 var categorySubtype = settings.PermissionValues.SESSION_ONLY; 595 var categorySubtype = settings.PermissionValues.SESSION_ONLY;
596 setUpCategory(contentType, categorySubtype, prefsSessionOnly); 596 setUpCategory(contentType, categorySubtype, prefsSessionOnly);
597 return browserProxy.whenCalled('getExceptionList').then( 597 return browserProxy.whenCalled('getExceptionList').then(
598 function(actualContentType) { 598 function(actualContentType) {
599 assertEquals(contentType, actualContentType); 599 assertEquals(contentType, actualContentType);
600 assertEquals(categorySubtype, testElement.categorySubtype); 600 assertEquals(categorySubtype, testElement.categorySubtype);
601 601
602 assertEquals(1, testElement.sites.length); 602 assertEquals(1, testElement.sites_.length);
603 assertEquals( 603 assertEquals(
604 prefsSessionOnly.exceptions.cookies[2].origin, 604 prefsSessionOnly.exceptions.cookies[2].origin,
605 testElement.sites[0].origin); 605 testElement.sites_[0].origin);
606 606
607 Polymer.dom.flush(); // Populates action menu. 607 Polymer.dom.flush(); // Populates action menu.
608 openActionMenu(0); 608 openActionMenu(0);
609 assertMenu(['Allow', 'Block', 'Edit', 'Remove'], testElement); 609 assertMenu(['Allow', 'Block', 'Edit', 'Remove'], testElement);
610 610
611 assertFalse(testElement.$.category.hidden); 611 assertFalse(testElement.$.category.hidden);
612 }); 612 });
613 }); 613 });
614 614
615 test('update lists for incognito', function() { 615 test('update lists for incognito', function() {
(...skipping 28 matching lines...) Expand all
644 644
645 test('initial INCOGNITO BLOCK state is correct', function() { 645 test('initial INCOGNITO BLOCK state is correct', function() {
646 var contentType = settings.ContentSettingsTypes.COOKIES; 646 var contentType = settings.ContentSettingsTypes.COOKIES;
647 var categorySubtype = settings.PermissionValues.BLOCK; 647 var categorySubtype = settings.PermissionValues.BLOCK;
648 setUpCategory(contentType, categorySubtype, prefsIncognito); 648 setUpCategory(contentType, categorySubtype, prefsIncognito);
649 return browserProxy.whenCalled('getExceptionList').then( 649 return browserProxy.whenCalled('getExceptionList').then(
650 function(actualContentType) { 650 function(actualContentType) {
651 assertEquals(contentType, actualContentType); 651 assertEquals(contentType, actualContentType);
652 assertEquals(categorySubtype, testElement.categorySubtype); 652 assertEquals(categorySubtype, testElement.categorySubtype);
653 653
654 assertEquals(1, testElement.sites.length); 654 assertEquals(1, testElement.sites_.length);
655 assertEquals( 655 assertEquals(
656 prefsIncognito.exceptions.cookies[0].origin, 656 prefsIncognito.exceptions.cookies[0].origin,
657 testElement.sites[0].origin); 657 testElement.sites_[0].origin);
658 658
659 Polymer.dom.flush(); // Populates action menu. 659 Polymer.dom.flush(); // Populates action menu.
660 openActionMenu(0); 660 openActionMenu(0);
661 // 'Clear on exit' is visible as this is not an incognito item. 661 // 'Clear on exit' is visible as this is not an incognito item.
662 assertMenu( 662 assertMenu(
663 ['Allow', 'Clear on exit', 'Edit', 'Remove'], testElement); 663 ['Allow', 'Clear on exit', 'Edit', 'Remove'], testElement);
664 664
665 // Select 'Remove' from menu. 665 // Select 'Remove' from menu.
666 var remove = testElement.$.reset; 666 var remove = testElement.$.reset;
667 assertTrue(!!remove); 667 assertTrue(!!remove);
(...skipping 10 matching lines...) Expand all
678 678
679 test('initial INCOGNITO ALLOW state is correct', function() { 679 test('initial INCOGNITO ALLOW state is correct', function() {
680 var contentType = settings.ContentSettingsTypes.COOKIES; 680 var contentType = settings.ContentSettingsTypes.COOKIES;
681 var categorySubtype = settings.PermissionValues.ALLOW; 681 var categorySubtype = settings.PermissionValues.ALLOW;
682 setUpCategory(contentType, categorySubtype, prefsIncognito); 682 setUpCategory(contentType, categorySubtype, prefsIncognito);
683 return browserProxy.whenCalled('getExceptionList').then( 683 return browserProxy.whenCalled('getExceptionList').then(
684 function(actualContentType) { 684 function(actualContentType) {
685 assertEquals(contentType, actualContentType); 685 assertEquals(contentType, actualContentType);
686 assertEquals(categorySubtype, testElement.categorySubtype); 686 assertEquals(categorySubtype, testElement.categorySubtype);
687 687
688 assertEquals(2, testElement.sites.length); 688 assertEquals(2, testElement.sites_.length);
689 assertEquals( 689 assertEquals(
690 prefsIncognito.exceptions.cookies[1].origin, 690 prefsIncognito.exceptions.cookies[1].origin,
691 testElement.sites[0].origin); 691 testElement.sites_[0].origin);
692 assertEquals( 692 assertEquals(
693 prefsIncognito.exceptions.cookies[2].origin, 693 prefsIncognito.exceptions.cookies[2].origin,
694 testElement.sites[1].origin); 694 testElement.sites_[1].origin);
695 695
696 Polymer.dom.flush(); // Populates action menu. 696 Polymer.dom.flush(); // Populates action menu.
697 openActionMenu(0); 697 openActionMenu(0);
698 // 'Clear on exit' is hidden for incognito items. 698 // 'Clear on exit' is hidden for incognito items.
699 assertMenu(['Block', 'Edit', 'Remove'], testElement); 699 assertMenu(['Block', 'Edit', 'Remove'], testElement);
700 closeActionMenu(); 700 closeActionMenu();
701 701
702 // Select 'Remove' from menu on 'foo.com'. 702 // Select 'Remove' from menu on 'foo.com'.
703 openActionMenu(1); 703 openActionMenu(1);
704 var remove = testElement.$.reset; 704 var remove = testElement.$.reset;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 var contentType = settings.ContentSettingsTypes.GEOLOCATION; 741 var contentType = settings.ContentSettingsTypes.GEOLOCATION;
742 setUpCategory(contentType, settings.PermissionValues.ALLOW, prefs); 742 setUpCategory(contentType, settings.PermissionValues.ALLOW, prefs);
743 return browserProxy.whenCalled('getExceptionList').then( 743 return browserProxy.whenCalled('getExceptionList').then(
744 function(actualContentType) { 744 function(actualContentType) {
745 assertEquals(contentType, actualContentType); 745 assertEquals(contentType, actualContentType);
746 746
747 // Required for firstItem to be found below. 747 // Required for firstItem to be found below.
748 Polymer.dom.flush(); 748 Polymer.dom.flush();
749 749
750 // Validate that the sites gets populated from pre-canned prefs. 750 // Validate that the sites gets populated from pre-canned prefs.
751 assertEquals(2, testElement.sites.length); 751 assertEquals(2, testElement.sites_.length);
752 assertEquals( 752 assertEquals(
753 prefs.exceptions.geolocation[0].origin, 753 prefs.exceptions.geolocation[0].origin,
754 testElement.sites[0].origin); 754 testElement.sites_[0].origin);
755 assertEquals( 755 assertEquals(
756 prefs.exceptions.geolocation[1].origin, 756 prefs.exceptions.geolocation[1].origin,
757 testElement.sites[1].origin); 757 testElement.sites_[1].origin);
758 assertFalse(!!testElement.selectedOrigin); 758 assertFalse(!!testElement.selectedOrigin);
759 759
760 // Validate that the sites are shown in UI and can be selected. 760 // Validate that the sites are shown in UI and can be selected.
761 var firstItem = testElement.$.listContainer.children[0]; 761 var firstItem = testElement.$.listContainer.children[0];
762 var clickable = firstItem.querySelector('.middle'); 762 var clickable = firstItem.querySelector('.middle');
763 assertTrue(!!clickable); 763 assertTrue(!!clickable);
764 MockInteractions.tap(clickable); 764 MockInteractions.tap(clickable);
765 assertEquals( 765 assertEquals(
766 prefs.exceptions.geolocation[0].origin, 766 prefs.exceptions.geolocation[0].origin,
767 settings.getQueryParameters().get('site')); 767 settings.getQueryParameters().get('site'));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // All Sites calls getExceptionList for all categories, starting 875 // All Sites calls getExceptionList for all categories, starting
876 // with Cookies. 876 // with Cookies.
877 assertEquals( 877 assertEquals(
878 settings.ContentSettingsTypes.COOKIES, contentType); 878 settings.ContentSettingsTypes.COOKIES, contentType);
879 879
880 // Required for firstItem to be found below. 880 // Required for firstItem to be found below.
881 Polymer.dom.flush(); 881 Polymer.dom.flush();
882 882
883 assertFalse(testElement.$.category.hidden); 883 assertFalse(testElement.$.category.hidden);
884 // Validate that the sites gets populated from pre-canned prefs. 884 // Validate that the sites gets populated from pre-canned prefs.
885 assertEquals(3, testElement.sites.length, 885 assertEquals(3, testElement.sites_.length,
886 'If this fails with 5 instead of the expected 3, then ' + 886 'If this fails with 5 instead of the expected 3, then ' +
887 'the de-duping of sites is not working for site_list'); 887 'the de-duping of sites is not working for site_list');
888 assertEquals(prefsVarious.exceptions.geolocation[1].origin, 888 assertEquals(prefsVarious.exceptions.geolocation[1].origin,
889 testElement.sites[0].origin); 889 testElement.sites_[0].origin);
890 assertEquals(prefsVarious.exceptions.geolocation[0].origin, 890 assertEquals(prefsVarious.exceptions.geolocation[0].origin,
891 testElement.sites[1].origin); 891 testElement.sites_[1].origin);
892 assertEquals(prefsVarious.exceptions.notifications[0].origin, 892 assertEquals(prefsVarious.exceptions.notifications[0].origin,
893 testElement.sites[2].origin); 893 testElement.sites_[2].origin);
894 assertEquals(undefined, testElement.selectedOrigin); 894 assertEquals(undefined, testElement.selectedOrigin);
895 895
896 // Validate that the sites are shown in UI and can be selected. 896 // Validate that the sites are shown in UI and can be selected.
897 var firstItem = testElement.$.listContainer.children[1]; 897 var firstItem = testElement.$.listContainer.children[1];
898 var clickable = firstItem.querySelector('.middle'); 898 var clickable = firstItem.querySelector('.middle');
899 assertNotEquals(undefined, clickable); 899 assertNotEquals(undefined, clickable);
900 MockInteractions.tap(clickable); 900 MockInteractions.tap(clickable);
901 assertEquals(prefsVarious.exceptions.geolocation[0].origin, 901 assertEquals(prefsVarious.exceptions.geolocation[0].origin,
902 settings.getQueryParameters().get('site')); 902 settings.getQueryParameters().get('site'));
903 }); 903 });
(...skipping 17 matching lines...) Expand all
921 settings.ContentSettingsTypes.COOKIES, contentType); 921 settings.ContentSettingsTypes.COOKIES, contentType);
922 922
923 // Required for firstItem to be found below. 923 // Required for firstItem to be found below.
924 Polymer.dom.flush(); 924 Polymer.dom.flush();
925 925
926 assertFalse(testElement.$.category.hidden); 926 assertFalse(testElement.$.category.hidden);
927 // Validate that the sites gets populated from pre-canned prefs. 927 // Validate that the sites gets populated from pre-canned prefs.
928 // TODO(dschuyler): de-duping of sites is under discussion, so 928 // TODO(dschuyler): de-duping of sites is under discussion, so
929 // it is currently disabled. It should be enabled again or this 929 // it is currently disabled. It should be enabled again or this
930 // code should be removed. 930 // code should be removed.
931 assertEquals(2, testElement.sites.length, 931 assertEquals(2, testElement.sites_.length,
932 'If this fails with 1 instead of the expected 2, then ' + 932 'If this fails with 1 instead of the expected 2, then ' +
933 'the de-duping of sites has been enabled for site_list.'); 933 'the de-duping of sites has been enabled for site_list.');
934 if (testElement.sites.length == 1) { 934 if (testElement.sites_.length == 1) {
935 assertEquals( 935 assertEquals(
936 prefsMixedOriginAndPattern.exceptions. 936 prefsMixedOriginAndPattern.exceptions.
937 geolocation[0]. 937 geolocation[0].
938 origin, 938 origin,
939 testElement.sites[0].displayName); 939 testElement.sites_[0].displayName);
940 } 940 }
941 941
942 assertEquals(undefined, testElement.selectedOrigin); 942 assertEquals(undefined, testElement.selectedOrigin);
943 // Validate that the sites are shown in UI and can be selected. 943 // Validate that the sites are shown in UI and can be selected.
944 var firstItem = testElement.$.listContainer.children[0]; 944 var firstItem = testElement.$.listContainer.children[0];
945 var clickable = firstItem.querySelector('.middle'); 945 var clickable = firstItem.querySelector('.middle');
946 assertNotEquals(undefined, clickable); 946 assertNotEquals(undefined, clickable);
947 MockInteractions.tap(clickable); 947 MockInteractions.tap(clickable);
948 if (testElement.sites.length == 1) { 948 if (testElement.sites_.length == 1) {
949 assertEquals( 949 assertEquals(
950 prefsMixedOriginAndPattern.exceptions. 950 prefsMixedOriginAndPattern.exceptions.
951 geolocation[0]. 951 geolocation[0].
952 origin, 952 origin,
953 testElement.sites[0].displayName); 953 testElement.sites_[0].displayName);
954 } 954 }
955 }); 955 });
956 }); 956 });
957 }); 957 });
958 958
959 test('Mixed schemes (present and absent)', function() { 959 test('Mixed schemes (present and absent)', function() {
960 // Prefs: One item with scheme and one without. 960 // Prefs: One item with scheme and one without.
961 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, 961 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
962 settings.PermissionValues.ALLOW, prefsMixedSchemes); 962 settings.PermissionValues.ALLOW, prefsMixedSchemes);
963 return browserProxy.whenCalled('getExceptionList').then( 963 return browserProxy.whenCalled('getExceptionList').then(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1071
1072 assertFalse(dialog.$.dialog.open); 1072 assertFalse(dialog.$.dialog.open);
1073 }); 1073 });
1074 }); 1074 });
1075 }); 1075 });
1076 1076
1077 return { 1077 return {
1078 registerTests: registerTests, 1078 registerTests: registerTests,
1079 }; 1079 };
1080 }); 1080 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_list.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698