| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 midiDevices: [], | 52 midiDevices: [], |
| 53 notifications: [], | 53 notifications: [], |
| 54 plugins: [], | 54 plugins: [], |
| 55 protectedContent: [], | 55 protectedContent: [], |
| 56 popups: [], | 56 popups: [], |
| 57 unsandboxed_plugins: [], | 57 unsandboxed_plugins: [], |
| 58 } | 58 } |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * An example of prefs controlleBy policy. |
| 63 * @type {SiteSettingsPref} |
| 64 */ |
| 65 var prefsControlled = { |
| 66 exceptions: { |
| 67 plugins: [ |
| 68 { |
| 69 category: 'plugins', |
| 70 embeddingOrigin: 'http://foo-block.com', |
| 71 origin: 'http://foo-block.com', |
| 72 setting: 'block', |
| 73 source: 'policy', |
| 74 }, |
| 75 ] |
| 76 } |
| 77 }; |
| 78 |
| 79 /** |
| 62 * An example pref with mixed schemes (present and absent). | 80 * An example pref with mixed schemes (present and absent). |
| 63 * @type {SiteSettingsPref} | 81 * @type {SiteSettingsPref} |
| 64 */ | 82 */ |
| 65 var prefsMixedSchemes = { | 83 var prefsMixedSchemes = { |
| 66 exceptions: { | 84 exceptions: { |
| 67 geolocation: [ | 85 geolocation: [ |
| 68 { | 86 { |
| 69 category: 'geolocation', | 87 category: 'geolocation', |
| 70 embeddingOrigin: 'https://foo-allow.com', | 88 embeddingOrigin: 'https://foo-allow.com', |
| 71 origin: 'https://foo-allow.com', | 89 origin: 'https://foo-allow.com', |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 testElement.sites[0].origin); | 605 testElement.sites[0].origin); |
| 588 | 606 |
| 589 Polymer.dom.flush(); // Populates action menu. | 607 Polymer.dom.flush(); // Populates action menu. |
| 590 openActionMenu(0); | 608 openActionMenu(0); |
| 591 assertMenu(['Allow', 'Block', 'Edit', 'Remove'], testElement); | 609 assertMenu(['Allow', 'Block', 'Edit', 'Remove'], testElement); |
| 592 | 610 |
| 593 assertFalse(testElement.$.category.hidden); | 611 assertFalse(testElement.$.category.hidden); |
| 594 }); | 612 }); |
| 595 }); | 613 }); |
| 596 | 614 |
| 615 test('update lists for incognito', function() { |
| 616 var contentType = settings.ContentSettingsTypes.PLUGINS; |
| 617 var categorySubtype = settings.PermissionValues.BLOCK; |
| 618 setUpCategory(contentType, categorySubtype, prefsControlled); |
| 619 var siteList = testElement.$$('#listContainer'); |
| 620 return browserProxy.whenCalled('getExceptionList').then( |
| 621 function(actualContentType) { |
| 622 Polymer.dom.flush(); |
| 623 assertEquals(1, siteList.querySelectorAll('.list-item').length); |
| 624 browserProxy.resetResolver('getExceptionList'); |
| 625 browserProxy.setIncognito(true); |
| 626 return browserProxy.whenCalled('getExceptionList'); |
| 627 }).then(function() { |
| 628 Polymer.dom.flush(); |
| 629 assertEquals(2, siteList.querySelectorAll('.list-item').length); |
| 630 browserProxy.resetResolver('getExceptionList'); |
| 631 browserProxy.setIncognito(false); |
| 632 return browserProxy.whenCalled('getExceptionList'); |
| 633 }).then(function() { |
| 634 Polymer.dom.flush(); |
| 635 assertEquals(1, siteList.querySelectorAll('.list-item').length); |
| 636 browserProxy.resetResolver('getExceptionList'); |
| 637 browserProxy.setIncognito(true); |
| 638 return browserProxy.whenCalled('getExceptionList'); |
| 639 }).then(function() { |
| 640 Polymer.dom.flush(); |
| 641 assertEquals(2, siteList.querySelectorAll('.list-item').length); |
| 642 }); |
| 643 }); |
| 644 |
| 597 test('initial INCOGNITO BLOCK state is correct', function() { | 645 test('initial INCOGNITO BLOCK state is correct', function() { |
| 598 var contentType = settings.ContentSettingsTypes.COOKIES; | 646 var contentType = settings.ContentSettingsTypes.COOKIES; |
| 599 var categorySubtype = settings.PermissionValues.BLOCK; | 647 var categorySubtype = settings.PermissionValues.BLOCK; |
| 600 setUpCategory(contentType, categorySubtype, prefsIncognito); | 648 setUpCategory(contentType, categorySubtype, prefsIncognito); |
| 601 return browserProxy.whenCalled('getExceptionList').then( | 649 return browserProxy.whenCalled('getExceptionList').then( |
| 602 function(actualContentType) { | 650 function(actualContentType) { |
| 603 assertEquals(contentType, actualContentType); | 651 assertEquals(contentType, actualContentType); |
| 604 assertEquals(categorySubtype, testElement.categorySubtype); | 652 assertEquals(categorySubtype, testElement.categorySubtype); |
| 605 | 653 |
| 606 assertEquals(1, testElement.sites.length); | 654 assertEquals(1, testElement.sites.length); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 | 1071 |
| 1024 assertFalse(dialog.$.dialog.open); | 1072 assertFalse(dialog.$.dialog.open); |
| 1025 }); | 1073 }); |
| 1026 }); | 1074 }); |
| 1027 }); | 1075 }); |
| 1028 | 1076 |
| 1029 return { | 1077 return { |
| 1030 registerTests: registerTests, | 1078 registerTests: registerTests, |
| 1031 }; | 1079 }; |
| 1032 }); | 1080 }); |
| OLD | NEW |