| Index: chrome/test/data/webui/settings/site_list_tests.js
|
| diff --git a/chrome/test/data/webui/settings/site_list_tests.js b/chrome/test/data/webui/settings/site_list_tests.js
|
| index 5fc88f63a8458161aa30d03b1dfc442473792660..594fb8a503f8b6ff005f5ab0e1c67e23f8890eef 100644
|
| --- a/chrome/test/data/webui/settings/site_list_tests.js
|
| +++ b/chrome/test/data/webui/settings/site_list_tests.js
|
| @@ -4,332 +4,333 @@
|
|
|
| /** @fileoverview Suite of tests for site-list. */
|
| cr.define('site_list', function() {
|
| - function registerTests() {
|
| - suite('SiteList', function() {
|
| - /**
|
| - * A site list element created before each test.
|
| - * @type {SiteList}
|
| - */
|
| - var testElement;
|
| + /**
|
| + * An example pref with 2 blocked location items and 2 allowed. This pref
|
| + * is also used for the All Sites category and therefore needs values for
|
| + * all types, even though some might be blank.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefs = {
|
| + exceptions: {
|
| + auto_downloads: [],
|
| + background_sync: [],
|
| + camera: [],
|
| + cookies: [],
|
| + geolocation: [
|
| + {
|
| + embeddingOrigin: 'https://bar-allow.com:443',
|
| + origin: 'https://bar-allow.com:443',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://foo-allow.com:443',
|
| + origin: 'https://foo-allow.com:443',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://bar-block.com:443',
|
| + origin: 'https://bar-block.com:443',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://foo-block.com:443',
|
| + origin: 'https://foo-block.com:443',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + ],
|
| + images: [],
|
| + javascript: [],
|
| + mic: [],
|
| + midiDevices: [],
|
| + notifications: [],
|
| + plugins: [],
|
| + protectedContent: [],
|
| + popups: [],
|
| + unsandboxed_plugins: [],
|
| + }
|
| + };
|
|
|
| - /**
|
| - * The mock proxy object to use during test.
|
| - * @type {TestSiteSettingsPrefsBrowserProxy}
|
| - */
|
| - var browserProxy = null;
|
| + /**
|
| + * An example pref with mixed schemes (present and absent).
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsMixedSchemes = {
|
| + exceptions: {
|
| + geolocation: [
|
| + {
|
| + embeddingOrigin: 'https://foo-allow.com',
|
| + origin: 'https://foo-allow.com',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'bar-allow.com',
|
| + origin: 'bar-allow.com',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + ]
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example pref with 2 blocked location items and 2 allowed. This pref
|
| - * is also used for the All Sites category and therefore needs values for
|
| - * all types, even though some might be blank.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefs = {
|
| - exceptions: {
|
| - auto_downloads: [],
|
| - background_sync: [],
|
| - camera: [],
|
| - cookies: [],
|
| - geolocation: [
|
| - {
|
| - embeddingOrigin: 'https://bar-allow.com:443',
|
| - origin: 'https://bar-allow.com:443',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://foo-allow.com:443',
|
| - origin: 'https://foo-allow.com:443',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://bar-block.com:443',
|
| - origin: 'https://bar-block.com:443',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://foo-block.com:443',
|
| - origin: 'https://foo-block.com:443',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - ],
|
| - images: [],
|
| - javascript: [],
|
| - mic: [],
|
| - midiDevices: [],
|
| - notifications: [],
|
| - plugins: [],
|
| - protectedContent: [],
|
| - popups: [],
|
| - unsandboxed_plugins: [],
|
| - }
|
| - };
|
|
|
| - /**
|
| - * An example pref with mixed schemes (present and absent).
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsMixedSchemes = {
|
| - exceptions: {
|
| - geolocation: [
|
| - {
|
| - embeddingOrigin: 'https://foo-allow.com',
|
| - origin: 'https://foo-allow.com',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'bar-allow.com',
|
| - origin: 'bar-allow.com',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - ]
|
| - }
|
| - };
|
| + /**
|
| + * An example pref with exceptions with origins and patterns from
|
| + * different providers.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsMixedProvider = {
|
| + exceptions: {
|
| + geolocation: [
|
| + {
|
| + embeddingOrigin: 'https://[*.]foo.com',
|
| + origin: 'https://[*.]foo.com',
|
| + setting: 'block',
|
| + source: 'policy',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://bar.foo.com',
|
| + origin: 'https://bar.foo.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://[*.]foo.com',
|
| + origin: 'https://[*.]foo.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + ]
|
| + }
|
| + };
|
|
|
| + /**
|
| + * An example pref with mixed origin and pattern.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsMixedOriginAndPattern = {
|
| + exceptions: {
|
| + auto_downloads: [],
|
| + background_sync: [],
|
| + camera: [],
|
| + cookies: [],
|
| + geolocation: [
|
| + {
|
| + origin: 'https://foo.com',
|
| + embeddingOrigin: '*',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + ],
|
| + images: [],
|
| + javascript: [
|
| + {
|
| + origin: 'https://[*.]foo.com',
|
| + embeddingOrigin: '*',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + ],
|
| + mic: [],
|
| + notifications: [],
|
| + plugins: [],
|
| + midiDevices: [],
|
| + protectedContent: [],
|
| + popups: [],
|
| + unsandboxed_plugins: [],
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example pref with exceptions with origins and patterns from
|
| - * different providers.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsMixedProvider = {
|
| - exceptions: {
|
| - geolocation: [
|
| - {
|
| - embeddingOrigin: 'https://[*.]foo.com',
|
| - origin: 'https://[*.]foo.com',
|
| - setting: 'block',
|
| - source: 'policy',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://bar.foo.com',
|
| - origin: 'https://bar.foo.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://[*.]foo.com',
|
| - origin: 'https://[*.]foo.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - ]
|
| - }
|
| - };
|
| + /**
|
| + * An example pref with multiple categories and multiple allow/block
|
| + * state.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsVarious = {
|
| + exceptions: {
|
| + auto_downloads: [],
|
| + background_sync: [],
|
| + camera: [],
|
| + cookies: [],
|
| + geolocation: [
|
| + {
|
| + embeddingOrigin: 'https://foo.com',
|
| + origin: 'https://foo.com',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://bar.com',
|
| + origin: 'https://bar.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + ],
|
| + images: [],
|
| + javascript: [],
|
| + mic: [],
|
| + midiDevices: [],
|
| + notifications: [
|
| + {
|
| + embeddingOrigin: 'https://google.com',
|
| + origin: 'https://google.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://bar.com',
|
| + origin: 'https://bar.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'https://foo.com',
|
| + origin: 'https://foo.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + ],
|
| + plugins: [],
|
| + protectedContent: [],
|
| + popups: [],
|
| + unsandboxed_plugins: [],
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example pref with mixed origin and pattern.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsMixedOriginAndPattern = {
|
| - exceptions: {
|
| - auto_downloads: [],
|
| - background_sync: [],
|
| - camera: [],
|
| - cookies: [],
|
| - geolocation: [
|
| - {
|
| - origin: 'https://foo.com',
|
| - embeddingOrigin: '*',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - ],
|
| - images: [],
|
| - javascript: [
|
| - {
|
| - origin: 'https://[*.]foo.com',
|
| - embeddingOrigin: '*',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - ],
|
| - mic: [],
|
| - notifications: [],
|
| - plugins: [],
|
| - midiDevices: [],
|
| - protectedContent: [],
|
| - popups: [],
|
| - unsandboxed_plugins: [],
|
| - }
|
| - };
|
| + /**
|
| + * An example pref with 1 allowed location item.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsOneEnabled = {
|
| + exceptions: {
|
| + geolocation: [
|
| + {
|
| + embeddingOrigin: 'https://foo-allow.com:443',
|
| + origin: 'https://foo-allow.com:443',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + ]
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example pref with multiple categories and multiple allow/block
|
| - * state.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsVarious = {
|
| - exceptions: {
|
| - auto_downloads: [],
|
| - background_sync: [],
|
| - camera: [],
|
| - cookies: [],
|
| - geolocation: [
|
| - {
|
| - embeddingOrigin: 'https://foo.com',
|
| - origin: 'https://foo.com',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://bar.com',
|
| - origin: 'https://bar.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - ],
|
| - images: [],
|
| - javascript: [],
|
| - mic: [],
|
| - midiDevices: [],
|
| - notifications: [
|
| - {
|
| - embeddingOrigin: 'https://google.com',
|
| - origin: 'https://google.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://bar.com',
|
| - origin: 'https://bar.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'https://foo.com',
|
| - origin: 'https://foo.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - ],
|
| - plugins: [],
|
| - protectedContent: [],
|
| - popups: [],
|
| - unsandboxed_plugins: [],
|
| - }
|
| - };
|
| + /**
|
| + * An example pref with 1 blocked location item.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsOneDisabled = {
|
| + exceptions: {
|
| + geolocation: [
|
| + {
|
| + embeddingOrigin: 'https://foo-block.com:443',
|
| + origin: 'https://foo-block.com:443',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + ]
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example pref with 1 allowed location item.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsOneEnabled = {
|
| - exceptions: {
|
| - geolocation: [
|
| - {
|
| - embeddingOrigin: 'https://foo-allow.com:443',
|
| - origin: 'https://foo-allow.com:443',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - ]
|
| - }
|
| - };
|
| + /**
|
| + * An example Cookies pref with 1 in each of the three categories.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsSessionOnly = {
|
| + exceptions: {
|
| + cookies: [
|
| + {
|
| + embeddingOrigin: 'http://foo-block.com',
|
| + origin: 'http://foo-block.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'http://foo-allow.com',
|
| + origin: 'http://foo-allow.com',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + {
|
| + embeddingOrigin: 'http://foo-session.com',
|
| + origin: 'http://foo-session.com',
|
| + setting: 'session_only',
|
| + source: 'preference',
|
| + },
|
| + ]
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example pref with 1 blocked location item.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsOneDisabled = {
|
| - exceptions: {
|
| - geolocation: [
|
| - {
|
| - embeddingOrigin: 'https://foo-block.com:443',
|
| - origin: 'https://foo-block.com:443',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - ]
|
| - }
|
| - };
|
| + /**
|
| + * An example Cookies pref with mixed incognito and regular settings.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsIncognito = {
|
| + exceptions: {
|
| + cookies: [
|
| + // foo.com is blocked for regular sessions.
|
| + {
|
| + embeddingOrigin: 'http://foo.com',
|
| + incognito: false,
|
| + origin: 'http://foo.com',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + // bar.com is an allowed incognito item without an embedder.
|
| + {
|
| + embeddingOrigin: '',
|
| + incognito: true,
|
| + origin: 'http://bar.com',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| + // foo.com is allowed in incognito (overridden).
|
| + {
|
| + embeddingOrigin: 'http://foo.com',
|
| + incognito: true,
|
| + origin: 'http://foo.com',
|
| + setting: 'allow',
|
| + source: 'preference',
|
| + },
|
| +
|
| + ]
|
| + }
|
| + };
|
|
|
| - /**
|
| - * An example Cookies pref with 1 in each of the three categories.
|
| - * @type {SiteSettingsPref}
|
| - */
|
| - var prefsSessionOnly = {
|
| - exceptions: {
|
| - cookies: [
|
| - {
|
| - embeddingOrigin: 'http://foo-block.com',
|
| - origin: 'http://foo-block.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'http://foo-allow.com',
|
| - origin: 'http://foo-allow.com',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - {
|
| - embeddingOrigin: 'http://foo-session.com',
|
| - origin: 'http://foo-session.com',
|
| - setting: 'session_only',
|
| - source: 'preference',
|
| - },
|
| - ]
|
| - }
|
| - };
|
| + /**
|
| + * An example Javascript pref with a chrome-extension:// scheme.
|
| + * @type {SiteSettingsPref}
|
| + */
|
| + var prefsChromeExtension = {
|
| + exceptions: {
|
| + javascript: [
|
| + {
|
| + embeddingOrigin: '',
|
| + origin: 'chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/',
|
| + setting: 'block',
|
| + source: 'preference',
|
| + },
|
| + ]
|
| + }
|
| + };
|
|
|
| + function registerTests() {
|
| + suite('SiteList', function() {
|
| /**
|
| - * An example Cookies pref with mixed incognito and regular settings.
|
| - * @type {SiteSettingsPref}
|
| + * A site list element created before each test.
|
| + * @type {SiteList}
|
| */
|
| - var prefsIncognito = {
|
| - exceptions: {
|
| - cookies: [
|
| - // foo.com is blocked for regular sessions.
|
| - {
|
| - embeddingOrigin: 'http://foo.com',
|
| - incognito: false,
|
| - origin: 'http://foo.com',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - // bar.com is an allowed incognito item without an embedder.
|
| - {
|
| - embeddingOrigin: '',
|
| - incognito: true,
|
| - origin: 'http://bar.com',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| - // foo.com is allowed in incognito (overridden).
|
| - {
|
| - embeddingOrigin: 'http://foo.com',
|
| - incognito: true,
|
| - origin: 'http://foo.com',
|
| - setting: 'allow',
|
| - source: 'preference',
|
| - },
|
| -
|
| - ]
|
| - }
|
| - };
|
| + var testElement;
|
|
|
| /**
|
| - * An example Javascript pref with a chrome-extension:// scheme.
|
| - * @type {SiteSettingsPref}
|
| + * The mock proxy object to use during test.
|
| + * @type {TestSiteSettingsPrefsBrowserProxy}
|
| */
|
| - var prefsChromeExtension = {
|
| - exceptions: {
|
| - javascript: [
|
| - {
|
| - embeddingOrigin: '',
|
| - origin: 'chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/',
|
| - setting: 'block',
|
| - source: 'preference',
|
| - },
|
| - ]
|
| - }
|
| - };
|
| + var browserProxy = null;
|
| +
|
|
|
| suiteSetup(function() {
|
| CrSettingsPrefs.setInitialized();
|
| @@ -356,15 +357,6 @@ cr.define('site_list', function() {
|
| });
|
|
|
| /**
|
| - * Fetch the non-hidden menu items from the action menu.
|
| - */
|
| - function getMenuItems() {
|
| - var menu = testElement.$$('dialog[is=cr-action-menu]');
|
| - assertTrue(!!menu);
|
| - return menu.querySelectorAll('button:not([hidden])');
|
| - }
|
| -
|
| - /**
|
| * Opens the action menu for a particular element in the list.
|
| * @param {number} index The index of the child element (which site) to
|
| * open the action menu for.
|
| @@ -388,7 +380,9 @@ cr.define('site_list', function() {
|
| * @param {Array<string>} items The items expected to show in the menu.
|
| */
|
| function assertMenu(items) {
|
| - var menuItems = getMenuItems();
|
| + var menu = testElement.$$('dialog[is=cr-action-menu]');
|
| + assertTrue(!!menu);
|
| + var menuItems = menu.querySelectorAll('button:not([hidden])');
|
| assertEquals(items.length, menuItems.length);
|
| for (var i = 0; i < items.length; i++)
|
| assertEquals(items[i], menuItems[i].textContent.trim());
|
| @@ -511,20 +505,21 @@ cr.define('site_list', function() {
|
| });
|
|
|
| test('initial BLOCK state is correct', function() {
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.BLOCK, prefs);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + var categorySubtype = settings.PermissionValues.BLOCK;
|
| + setUpCategory(contentType, categorySubtype, prefs);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| + assertEquals(categorySubtype, testElement.categorySubtype);
|
|
|
| assertEquals(2, testElement.sites.length);
|
| - assertEquals(prefs.exceptions.geolocation[2].origin,
|
| + assertEquals(
|
| + prefs.exceptions.geolocation[2].origin,
|
| testElement.sites[0].origin);
|
| - assertEquals(prefs.exceptions.geolocation[3].origin,
|
| - testElement.sites[1].origin);
|
| assertEquals(
|
| - settings.PermissionValues.BLOCK, testElement.categorySubtype);
|
| + prefs.exceptions.geolocation[3].origin,
|
| + testElement.sites[1].origin);
|
| Polymer.dom.flush(); // Populates action menu.
|
| openActionMenu(0);
|
| assertMenu(['Allow', 'Remove'], testElement);
|
| @@ -534,134 +529,159 @@ cr.define('site_list', function() {
|
| });
|
|
|
| test('initial SESSION ONLY state is correct', function() {
|
| - setUpCategory(settings.ContentSettingsTypes.COOKIES,
|
| - settings.PermissionValues.SESSION_ONLY, prefsSessionOnly);
|
| + var contentType = settings.ContentSettingsTypes.COOKIES;
|
| + var categorySubtype = settings.PermissionValues.SESSION_ONLY;
|
| + setUpCategory(contentType, categorySubtype, prefsSessionOnly);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.COOKIES, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| + assertEquals(categorySubtype, testElement.categorySubtype);
|
|
|
| assertEquals(1, testElement.sites.length);
|
| - assertEquals(prefsSessionOnly.exceptions.cookies[2].origin,
|
| + assertEquals(
|
| + prefsSessionOnly.exceptions.cookies[2].origin,
|
| testElement.sites[0].origin);
|
|
|
| - assertEquals(settings.PermissionValues.SESSION_ONLY,
|
| - testElement.categorySubtype);
|
| Polymer.dom.flush(); // Populates action menu.
|
| openActionMenu(0);
|
| - assertMenu(['Allow', 'Block', 'Remove'], testElement);
|
| + assertMenu(['Allow', 'Block', 'Edit', 'Remove'], testElement);
|
|
|
| assertFalse(testElement.$.category.hidden);
|
| });
|
| });
|
|
|
| test('initial INCOGNITO BLOCK state is correct', function() {
|
| - setUpCategory(settings.ContentSettingsTypes.COOKIES,
|
| - settings.PermissionValues.BLOCK, prefsIncognito);
|
| + var contentType = settings.ContentSettingsTypes.COOKIES;
|
| + var categorySubtype = settings.PermissionValues.BLOCK;
|
| + setUpCategory(contentType, categorySubtype, prefsIncognito);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(settings.ContentSettingsTypes.COOKIES, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| + assertEquals(categorySubtype, testElement.categorySubtype);
|
|
|
| assertEquals(1, testElement.sites.length);
|
| - assertEquals(prefsIncognito.exceptions.cookies[0].origin,
|
| + assertEquals(
|
| + prefsIncognito.exceptions.cookies[0].origin,
|
| testElement.sites[0].origin);
|
|
|
| - assertEquals(settings.PermissionValues.BLOCK,
|
| - testElement.categorySubtype);
|
| Polymer.dom.flush(); // Populates action menu.
|
| openActionMenu(0);
|
| // 'Clear on exit' is visible as this is not an incognito item.
|
| - assertMenu(['Allow', 'Clear on exit', 'Remove'], testElement);
|
| + assertMenu(
|
| + ['Allow', 'Clear on exit', 'Edit', 'Remove'], testElement);
|
|
|
| - // Select 'Remove from menu'.
|
| - var menuItems = getMenuItems();
|
| - assertTrue(!!menuItems);
|
| - MockInteractions.tap(menuItems[2]);
|
| + // Select 'Remove' from menu.
|
| + var remove = testElement.$.reset;
|
| + assertTrue(!!remove);
|
| + MockInteractions.tap(remove);
|
| return browserProxy.whenCalled(
|
| 'resetCategoryPermissionForOrigin');
|
| }).then(function(args) {
|
| assertEquals('http://foo.com', args[0]);
|
| assertEquals('http://foo.com', args[1]);
|
| - assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]);
|
| + assertEquals(contentType, args[2]);
|
| assertFalse(args[3]); // Incognito.
|
| });
|
| });
|
|
|
| test('initial INCOGNITO ALLOW state is correct', function() {
|
| - setUpCategory(settings.ContentSettingsTypes.COOKIES,
|
| - settings.PermissionValues.ALLOW, prefsIncognito);
|
| + var contentType = settings.ContentSettingsTypes.COOKIES;
|
| + var categorySubtype = settings.PermissionValues.ALLOW;
|
| + setUpCategory(contentType, categorySubtype, prefsIncognito);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.COOKIES, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| + assertEquals(categorySubtype, testElement.categorySubtype);
|
|
|
| assertEquals(2, testElement.sites.length);
|
| - assertEquals(prefsIncognito.exceptions.cookies[1].origin,
|
| + assertEquals(
|
| + prefsIncognito.exceptions.cookies[1].origin,
|
| testElement.sites[0].origin);
|
| - assertEquals(prefsIncognito.exceptions.cookies[2].origin,
|
| + assertEquals(
|
| + prefsIncognito.exceptions.cookies[2].origin,
|
| testElement.sites[1].origin);
|
|
|
| - assertEquals(settings.PermissionValues.ALLOW,
|
| - testElement.categorySubtype);
|
| Polymer.dom.flush(); // Populates action menu.
|
| openActionMenu(0);
|
| // 'Clear on exit' is hidden for incognito items.
|
| - assertMenu(['Block', 'Remove'], testElement);
|
| + assertMenu(['Block', 'Edit', 'Remove'], testElement);
|
| closeActionMenu();
|
|
|
| // Select 'Remove' from menu on 'foo.com'.
|
| openActionMenu(1);
|
| - var menuItems = getMenuItems();
|
| - assertTrue(!!menuItems);
|
| - MockInteractions.tap(menuItems[1]);
|
| + var remove = testElement.$.reset;
|
| + assertTrue(!!remove);
|
| + MockInteractions.tap(remove);
|
| return browserProxy.whenCalled(
|
| 'resetCategoryPermissionForOrigin');
|
| }).then(function(args) {
|
| assertEquals('http://foo.com', args[0]);
|
| assertEquals('http://foo.com', args[1]);
|
| - assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]);
|
| + assertEquals(contentType, args[2]);
|
| assertTrue(args[3]); // Incognito.
|
| });
|
| });
|
|
|
| + test('edit action menu opens edit exception dialog', function() {
|
| + setUpCategory(
|
| + settings.ContentSettingsTypes.COOKIES,
|
| + settings.PermissionValues.SESSION_ONLY,
|
| + prefsSessionOnly);
|
| +
|
| + return browserProxy.whenCalled('getExceptionList').then(function() {
|
| + Polymer.dom.flush(); // Populates action menu.
|
| +
|
| + openActionMenu(0);
|
| + assertMenu(['Allow', 'Block', 'Edit', 'Remove'], testElement);
|
| + var edit = testElement.$.edit;
|
| + assertTrue(!!edit);
|
| + MockInteractions.tap(edit);
|
| + Polymer.dom.flush();
|
| +
|
| + assertTrue(!!testElement.$$('settings-edit-exception-dialog'));
|
| + });
|
| + });
|
| +
|
| test('list items shown and clickable when data is present', function() {
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.ALLOW, prefs);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(contentType, settings.PermissionValues.ALLOW, prefs);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| + function(actualContentType) {
|
| testElement.enableSiteSettings_ = true;
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + assertEquals(contentType, actualContentType);
|
|
|
| // Required for firstItem to be found below.
|
| Polymer.dom.flush();
|
|
|
| // Validate that the sites gets populated from pre-canned prefs.
|
| assertEquals(2, testElement.sites.length);
|
| - assertEquals(prefs.exceptions.geolocation[0].origin,
|
| + assertEquals(
|
| + prefs.exceptions.geolocation[0].origin,
|
| testElement.sites[0].origin);
|
| - assertEquals(prefs.exceptions.geolocation[1].origin,
|
| + assertEquals(
|
| + prefs.exceptions.geolocation[1].origin,
|
| testElement.sites[1].origin);
|
| - assertEquals(undefined, testElement.selectedOrigin);
|
| + assertFalse(!!testElement.selectedOrigin);
|
|
|
| // Validate that the sites are shown in UI and can be selected.
|
| var firstItem = testElement.$.listContainer.children[0];
|
| var clickable = firstItem.querySelector('.middle');
|
| - assertNotEquals(undefined, clickable);
|
| + assertTrue(!!clickable);
|
| MockInteractions.tap(clickable);
|
| - assertEquals(prefs.exceptions.geolocation[0].origin,
|
| + assertEquals(
|
| + prefs.exceptions.geolocation[0].origin,
|
| settings.getQueryParameters().get('site'));
|
| });
|
| });
|
|
|
| test('Block list open when Allow list is empty', function() {
|
| // Prefs: One item in Block list, nothing in Allow list.
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.BLOCK, prefsOneDisabled);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(
|
| + contentType, settings.PermissionValues.BLOCK, prefsOneDisabled);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| assertFalse(testElement.$.category.hidden);
|
| }).then(function() {
|
| assertNotEquals(0, testElement.$.listContainer.offsetHeight);
|
| @@ -670,12 +690,11 @@ cr.define('site_list', function() {
|
|
|
| test('Block list closed when Allow list is not empty', function() {
|
| // Prefs: Items in both Block and Allow list.
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.BLOCK, prefs);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(contentType, settings.PermissionValues.BLOCK, prefs);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| assertFalse(testElement.$.category.hidden);
|
| assertEquals(0, testElement.$.listContainer.offsetHeight);
|
| });
|
| @@ -683,13 +702,12 @@ cr.define('site_list', function() {
|
|
|
| test('Allow list is always open (Block list empty)', function() {
|
| // Prefs: One item in Allow list, nothing in Block list.
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.ALLOW, prefsOneEnabled);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(
|
| + contentType, settings.PermissionValues.ALLOW, prefsOneEnabled);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| -
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| assertFalse(testElement.$.category.hidden);
|
| }).then(function() {
|
| assertNotEquals(0, testElement.$.listContainer.offsetHeight);
|
| @@ -698,12 +716,11 @@ cr.define('site_list', function() {
|
|
|
| test('Allow list is always open (Block list non-empty)', function() {
|
| // Prefs: Items in both Block and Allow list.
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.ALLOW, prefs);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(contentType, settings.PermissionValues.ALLOW, prefs);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| assertFalse(testElement.$.category.hidden);
|
| }).then(function() {
|
| assertNotEquals(0, testElement.$.listContainer.offsetHeight);
|
| @@ -712,24 +729,24 @@ cr.define('site_list', function() {
|
|
|
| test('Block list not hidden when empty', function() {
|
| // Prefs: One item in Allow list, nothing in Block list.
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.BLOCK, prefsOneEnabled);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(
|
| + contentType, settings.PermissionValues.BLOCK, prefsOneEnabled);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| assertFalse(testElement.$.category.hidden);
|
| });
|
| });
|
|
|
| test('Allow list not hidden when empty', function() {
|
| // Prefs: One item in Block list, nothing in Allow list.
|
| - setUpCategory(settings.ContentSettingsTypes.GEOLOCATION,
|
| - settings.PermissionValues.ALLOW, prefsOneDisabled);
|
| + var contentType = settings.ContentSettingsTypes.GEOLOCATION;
|
| + setUpCategory(
|
| + contentType, settings.PermissionValues.ALLOW, prefsOneDisabled);
|
| return browserProxy.whenCalled('getExceptionList').then(
|
| - function(contentType) {
|
| - assertEquals(
|
| - settings.ContentSettingsTypes.GEOLOCATION, contentType);
|
| + function(actualContentType) {
|
| + assertEquals(contentType, actualContentType);
|
| assertFalse(testElement.$.category.hidden);
|
| });
|
| });
|
| @@ -865,9 +882,9 @@ cr.define('site_list', function() {
|
| contentType) {
|
| Polymer.dom.flush();
|
| openActionMenu(0);
|
| - var menuItems = getMenuItems();
|
| - assertTrue(!!menuItems);
|
| - MockInteractions.tap(menuItems[0]);
|
| + var allow = testElement.$.allow;
|
| + assertTrue(!!allow);
|
| + MockInteractions.tap(allow);
|
| return browserProxy.whenCalled('setCategoryPermissionForOrigin');
|
| });
|
| });
|
| @@ -881,9 +898,9 @@ cr.define('site_list', function() {
|
| openActionMenu(0);
|
| assertMenu(['Allow', 'Remove'], testElement);
|
|
|
| - var menuItems = getMenuItems();
|
| - assertTrue(!!menuItems);
|
| - MockInteractions.tap(menuItems[0]); // Action: Allow.
|
| + var allow = testElement.$.allow;
|
| + assertTrue(!!allow);
|
| + MockInteractions.tap(allow);
|
| return browserProxy.whenCalled('setCategoryPermissionForOrigin');
|
| }).then(function(args) {
|
| assertEquals('chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/',
|
| @@ -895,6 +912,76 @@ cr.define('site_list', function() {
|
| });
|
| });
|
| }
|
| +
|
| + suite('EditExceptionDialog', function() {
|
| + var dialog;
|
| + var cookieException = prefsIncognito.exceptions.cookies[0];
|
| +
|
| + setup(function() {
|
| + browserProxy = new TestSiteSettingsPrefsBrowserProxy();
|
| + settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy;
|
| + PolymerTest.clearBody();
|
| + dialog = document.createElement('settings-edit-exception-dialog');
|
| + dialog.model = cookieException;
|
| + document.body.appendChild(dialog);
|
| + });
|
| +
|
| + teardown(function() {
|
| + dialog.remove();
|
| + });
|
| +
|
| + test('action button disabled on invalid input', function() {
|
| + var input = dialog.$$('paper-input');
|
| + assertTrue(!!input);
|
| + var actionButton = dialog.$.actionButton;
|
| + assertTrue(!!actionButton);
|
| + assertFalse(actionButton.disabled);
|
| +
|
| + browserProxy.setIsPatternValid(false);
|
| + var expectedPattern = 'foobarbaz';
|
| + // Simulate user input.
|
| + input.value = expectedPattern;
|
| + input.fire('input');
|
| +
|
| + return browserProxy.whenCalled('isPatternValid').then(function(pattern) {
|
| + assertEquals(expectedPattern, pattern);
|
| + assertTrue(actionButton.disabled);
|
| + });
|
| + });
|
| +
|
| + test('action button calls proxy', function() {
|
| + var input = dialog.$$('paper-input');
|
| + assertTrue(!!input);
|
| + // Simulate user edit.
|
| + var newValue = input.value + ':1234';
|
| + input.value = newValue;
|
| +
|
| + var actionButton = dialog.$.actionButton;
|
| + assertTrue(!!actionButton);
|
| + assertFalse(actionButton.disabled);
|
| +
|
| + MockInteractions.tap(actionButton);
|
| +
|
| + return browserProxy.whenCalled('resetCategoryPermissionForOrigin').then(
|
| + function(args) {
|
| + assertEquals(cookieException.origin, args[0]);
|
| + assertEquals(cookieException.embeddingOrigin, args[1]);
|
| + assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]);
|
| + assertEquals(cookieException.incognito, args[3]);
|
| +
|
| + return browserProxy.whenCalled('setCategoryPermissionForOrigin');
|
| + }).then(function(args) {
|
| + assertEquals(newValue, args[0]);
|
| + assertEquals(newValue, args[1]);
|
| + assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]);
|
| + assertEquals(cookieException.setting, args[3]);
|
| + assertEquals(cookieException.incognito, args[4]);
|
| +
|
| + assertFalse(dialog.$.dialog.open);
|
| + });
|
| + });
|
| + });
|
| +
|
| return {
|
| registerTests: registerTests,
|
| };
|
|
|