| 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 /** | 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 settings.resetRouteForTesting(); | 381 settings.resetRouteForTesting(); |
| 382 }); | 382 }); |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * Opens the action menu for a particular element in the list. | 385 * Opens the action menu for a particular element in the list. |
| 386 * @param {number} index The index of the child element (which site) to | 386 * @param {number} index The index of the child element (which site) to |
| 387 * open the action menu for. | 387 * open the action menu for. |
| 388 */ | 388 */ |
| 389 function openActionMenu(index) { | 389 function openActionMenu(index) { |
| 390 var item = testElement.$.listContainer.children[index]; | 390 var item = testElement.$.listContainer.children[index]; |
| 391 var dots = item.querySelector('paper-icon-button'); | 391 var dots = item.querySelector('#actionMenuButton'); |
| 392 MockInteractions.tap(dots); | 392 MockInteractions.tap(dots); |
| 393 Polymer.dom.flush(); | 393 Polymer.dom.flush(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 /** Closes the action menu. */ | 396 /** Closes the action menu. */ |
| 397 function closeActionMenu() { | 397 function closeActionMenu() { |
| 398 var menu = testElement.$$('dialog[is=cr-action-menu]'); | 398 var menu = testElement.$$('dialog[is=cr-action-menu]'); |
| 399 if (menu.open) | 399 if (menu.open) |
| 400 menu.close(); | 400 menu.close(); |
| 401 } | 401 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 | 439 |
| 440 test('read-only attribute', function() { | 440 test('read-only attribute', function() { |
| 441 setUpCategory( | 441 setUpCategory( |
| 442 settings.ContentSettingsTypes.GEOLOCATION, | 442 settings.ContentSettingsTypes.GEOLOCATION, |
| 443 settings.PermissionValues.ALLOW, prefsVarious); | 443 settings.PermissionValues.ALLOW, prefsVarious); |
| 444 return browserProxy.whenCalled('getExceptionList') | 444 return browserProxy.whenCalled('getExceptionList') |
| 445 .then(function(contentType) { | 445 .then(function(contentType) { |
| 446 // Flush to be sure list container is populated. | 446 // Flush to be sure list container is populated. |
| 447 Polymer.dom.flush(); | 447 Polymer.dom.flush(); |
| 448 var dotsMenu = testElement.$.listContainer.querySelector('#dots'); | 448 var dotsMenu = testElement.$.listContainer.querySelector( |
| 449 '#actionMenuButton'); |
| 449 assertFalse(dotsMenu.hidden); | 450 assertFalse(dotsMenu.hidden); |
| 450 testElement.setAttribute('read-only-list', true); | 451 testElement.setAttribute('read-only-list', true); |
| 451 Polymer.dom.flush(); | 452 Polymer.dom.flush(); |
| 452 assertTrue(dotsMenu.hidden); | 453 assertTrue(dotsMenu.hidden); |
| 453 testElement.removeAttribute('read-only-list'); | 454 testElement.removeAttribute('read-only-list'); |
| 454 Polymer.dom.flush(); | 455 Polymer.dom.flush(); |
| 455 assertFalse(dotsMenu.hidden); | 456 assertFalse(dotsMenu.hidden); |
| 456 }); | 457 }); |
| 457 }); | 458 }); |
| 458 | 459 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 return browserProxy.whenCalled( | 660 return browserProxy.whenCalled( |
| 660 'resetCategoryPermissionForOrigin'); | 661 'resetCategoryPermissionForOrigin'); |
| 661 }).then(function(args) { | 662 }).then(function(args) { |
| 662 assertEquals('http://foo.com', args[0]); | 663 assertEquals('http://foo.com', args[0]); |
| 663 assertEquals('http://foo.com', args[1]); | 664 assertEquals('http://foo.com', args[1]); |
| 664 assertEquals(contentType, args[2]); | 665 assertEquals(contentType, args[2]); |
| 665 assertTrue(args[3]); // Incognito. | 666 assertTrue(args[3]); // Incognito. |
| 666 }); | 667 }); |
| 667 }); | 668 }); |
| 668 | 669 |
| 670 test('reset button works for read-only content types', function() { |
| 671 testElement.readOnlyList = true; |
| 672 Polymer.dom.flush(); |
| 673 |
| 674 var contentType = settings.ContentSettingsTypes.GEOLOCATION; |
| 675 var categorySubtype = settings.PermissionValues.ALLOW; |
| 676 setUpCategory(contentType, categorySubtype, prefsOneEnabled); |
| 677 return browserProxy.whenCalled('getExceptionList') |
| 678 .then(function(actualContentType) { |
| 679 assertEquals(contentType, actualContentType); |
| 680 assertEquals(categorySubtype, testElement.categorySubtype); |
| 681 |
| 682 assertEquals(1, testElement.sites.length); |
| 683 assertEquals( |
| 684 prefsOneEnabled.exceptions.geolocation[0].origin, |
| 685 testElement.sites[0].origin); |
| 686 |
| 687 Polymer.dom.flush(); |
| 688 |
| 689 var item = testElement.$.listContainer.children[0]; |
| 690 |
| 691 // Assert action button is hidden. |
| 692 var dots = item.querySelector('#actionMenuButton'); |
| 693 assertTrue(!!dots); |
| 694 assertTrue(dots.hidden); |
| 695 |
| 696 // Assert reset button is visible. |
| 697 var resetButton = item.querySelector('#resetSite'); |
| 698 assertTrue(!!resetButton); |
| 699 assertFalse(resetButton.hidden); |
| 700 |
| 701 MockInteractions.tap(resetButton); |
| 702 return browserProxy.whenCalled( |
| 703 'resetCategoryPermissionForOrigin'); |
| 704 }) |
| 705 .then(function(args) { |
| 706 assertEquals('https://foo-allow.com:443', args[0]); |
| 707 assertEquals('https://foo-allow.com:443', args[1]); |
| 708 assertEquals(contentType, args[2]); |
| 709 }); |
| 710 }); |
| 711 |
| 669 test('edit action menu opens edit exception dialog', function() { | 712 test('edit action menu opens edit exception dialog', function() { |
| 670 setUpCategory( | 713 setUpCategory( |
| 671 settings.ContentSettingsTypes.COOKIES, | 714 settings.ContentSettingsTypes.COOKIES, |
| 672 settings.PermissionValues.SESSION_ONLY, | 715 settings.PermissionValues.SESSION_ONLY, |
| 673 prefsSessionOnly); | 716 prefsSessionOnly); |
| 674 | 717 |
| 675 return browserProxy.whenCalled('getExceptionList').then(function() { | 718 return browserProxy.whenCalled('getExceptionList').then(function() { |
| 676 Polymer.dom.flush(); // Populates action menu. | 719 Polymer.dom.flush(); // Populates action menu. |
| 677 | 720 |
| 678 openActionMenu(0); | 721 openActionMenu(0); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 842 |
| 800 test('All sites category no action menu', function() { | 843 test('All sites category no action menu', function() { |
| 801 setUpCategory(settings.ALL_SITES, '', prefsVarious); | 844 setUpCategory(settings.ALL_SITES, '', prefsVarious); |
| 802 return browserProxy.whenCalled('getExceptionList').then( | 845 return browserProxy.whenCalled('getExceptionList').then( |
| 803 function(contentType) { | 846 function(contentType) { |
| 804 // Use resolver to ensure that the list container is populated. | 847 // Use resolver to ensure that the list container is populated. |
| 805 var resolver = new PromiseResolver(); | 848 var resolver = new PromiseResolver(); |
| 806 testElement.async(resolver.resolve); | 849 testElement.async(resolver.resolve); |
| 807 return resolver.promise.then(function() { | 850 return resolver.promise.then(function() { |
| 808 var item = testElement.$.listContainer.children[0]; | 851 var item = testElement.$.listContainer.children[0]; |
| 809 var dots = item.querySelector('paper-icon-button'); | 852 var dots = item.querySelector('#actionMenuButton'); |
| 810 assertTrue(!!dots); | 853 assertTrue(!!dots); |
| 811 assertTrue(dots.hidden); | 854 assertTrue(dots.hidden); |
| 812 }); | 855 }); |
| 813 }); | 856 }); |
| 814 }); | 857 }); |
| 815 | 858 |
| 816 test('All sites category', function() { | 859 test('All sites category', function() { |
| 817 // Prefs: Multiple and overlapping sites. | 860 // Prefs: Multiple and overlapping sites. |
| 818 setUpCategory(settings.ALL_SITES, '', prefsVarious); | 861 setUpCategory(settings.ALL_SITES, '', prefsVarious); |
| 819 | 862 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 | 1066 |
| 1024 assertFalse(dialog.$.dialog.open); | 1067 assertFalse(dialog.$.dialog.open); |
| 1025 }); | 1068 }); |
| 1026 }); | 1069 }); |
| 1027 }); | 1070 }); |
| 1028 | 1071 |
| 1029 return { | 1072 return { |
| 1030 registerTests: registerTests, | 1073 registerTests: registerTests, |
| 1031 }; | 1074 }; |
| 1032 }); | 1075 }); |
| OLD | NEW |