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

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

Issue 2862463002: [MD settings] split up site settings tests (Closed)
Patch Set: CategoryDefaultSetting fix Created 3 years, 7 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
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-details. */ 5 /** @fileoverview Suite of tests for site-details. */
6 cr.define('site_details', function() { 6 suite('SiteDetails', function() {
7 function registerTests() { 7 /**
8 suite('SiteDetails', function() { 8 * A site list element created before each test.
9 /** 9 * @type {SiteDetails}
10 * A site list element created before each test. 10 */
11 * @type {SiteDetails} 11 var testElement;
12 */
13 var testElement;
14 12
15 /** 13 /**
16 * An example pref with 1 allowed in each category. 14 * An example pref with 1 allowed in each category.
17 */ 15 */
18 var prefs = { 16 var prefs = {
19 exceptions: { 17 exceptions: {
20 auto_downloads: [ 18 auto_downloads: [
21 { 19 {
22 embeddingOrigin: 'https://foo-allow.com:443', 20 embeddingOrigin: 'https://foo-allow.com:443',
23 origin: 'https://foo-allow.com:443', 21 origin: 'https://foo-allow.com:443',
24 setting: 'allow', 22 setting: 'allow',
25 source: 'preference', 23 source: 'preference',
26 }, 24 },
27 ], 25 ],
28 background_sync: [ 26 background_sync: [
29 { 27 {
30 embeddingOrigin: 'https://foo-allow.com:443', 28 embeddingOrigin: 'https://foo-allow.com:443',
31 origin: 'https://foo-allow.com:443', 29 origin: 'https://foo-allow.com:443',
32 setting: 'allow', 30 setting: 'allow',
33 source: 'preference', 31 source: 'preference',
34 }, 32 },
35 ], 33 ],
36 camera: [ 34 camera: [
37 { 35 {
38 embeddingOrigin: 'https://foo-allow.com:443', 36 embeddingOrigin: 'https://foo-allow.com:443',
39 origin: 'https://foo-allow.com:443', 37 origin: 'https://foo-allow.com:443',
40 setting: 'allow', 38 setting: 'allow',
41 source: 'preference', 39 source: 'preference',
42 }, 40 },
43 ], 41 ],
44 cookies: [ 42 cookies: [
45 { 43 {
46 embeddingOrigin: 'https://foo-allow.com:443', 44 embeddingOrigin: 'https://foo-allow.com:443',
47 origin: 'https://foo-allow.com:443', 45 origin: 'https://foo-allow.com:443',
48 setting: 'allow', 46 setting: 'allow',
49 source: 'preference', 47 source: 'preference',
50 }, 48 },
51 ], 49 ],
52 geolocation: [ 50 geolocation: [
53 { 51 {
54 embeddingOrigin: 'https://foo-allow.com:443', 52 embeddingOrigin: 'https://foo-allow.com:443',
55 origin: 'https://foo-allow.com:443', 53 origin: 'https://foo-allow.com:443',
56 setting: 'allow', 54 setting: 'allow',
57 source: 'preference', 55 source: 'preference',
58 }, 56 },
59 ], 57 ],
60 javascript: [ 58 javascript: [
61 { 59 {
62 embeddingOrigin: 'https://foo-allow.com:443', 60 embeddingOrigin: 'https://foo-allow.com:443',
63 origin: 'https://foo-allow.com:443', 61 origin: 'https://foo-allow.com:443',
64 setting: 'allow', 62 setting: 'allow',
65 source: 'preference', 63 source: 'preference',
66 }, 64 },
67 ], 65 ],
68 mic: [ 66 mic: [
69 { 67 {
70 embeddingOrigin: 'https://foo-allow.com:443', 68 embeddingOrigin: 'https://foo-allow.com:443',
71 origin: 'https://foo-allow.com:443', 69 origin: 'https://foo-allow.com:443',
72 setting: 'allow', 70 setting: 'allow',
73 source: 'preference', 71 source: 'preference',
74 }, 72 },
75 ], 73 ],
76 notifications: [ 74 notifications: [
77 { 75 {
78 embeddingOrigin: 'https://foo-allow.com:443', 76 embeddingOrigin: 'https://foo-allow.com:443',
79 origin: 'https://foo-allow.com:443', 77 origin: 'https://foo-allow.com:443',
80 setting: 'allow', 78 setting: 'allow',
81 source: 'preference', 79 source: 'preference',
82 }, 80 },
83 ], 81 ],
84 plugins: [ 82 plugins: [
85 { 83 {
86 embeddingOrigin: 'https://foo-allow.com:443', 84 embeddingOrigin: 'https://foo-allow.com:443',
87 origin: 'https://foo-allow.com:443', 85 origin: 'https://foo-allow.com:443',
88 setting: 'allow', 86 setting: 'allow',
89 source: 'preference', 87 source: 'preference',
90 }, 88 },
91 ], 89 ],
92 popups: [ 90 popups: [
93 { 91 {
94 embeddingOrigin: 'https://foo-allow.com:443', 92 embeddingOrigin: 'https://foo-allow.com:443',
95 origin: 'https://foo-allow.com:443', 93 origin: 'https://foo-allow.com:443',
96 setting: 'allow', 94 setting: 'allow',
97 source: 'preference', 95 source: 'preference',
98 }, 96 },
99 ], 97 ],
100 unsandboxed_plugins: [ 98 unsandboxed_plugins: [
101 { 99 {
102 embeddingOrigin: 'https://foo-allow.com:443', 100 embeddingOrigin: 'https://foo-allow.com:443',
103 origin: 'https://foo-allow.com:443', 101 origin: 'https://foo-allow.com:443',
104 setting: 'allow', 102 setting: 'allow',
105 source: 'preference', 103 source: 'preference',
106 }, 104 },
107 ], 105 ],
108 } 106 }
109 }; 107 };
110 108
111 // Initialize a site-details before each test. 109 // Initialize a site-details before each test.
112 setup(function() { 110 setup(function() {
113 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); 111 browserProxy = new TestSiteSettingsPrefsBrowserProxy();
114 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; 112 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy;
115 PolymerTest.clearBody(); 113 PolymerTest.clearBody();
116 testElement = document.createElement('site-details'); 114 testElement = document.createElement('site-details');
117 document.body.appendChild(testElement); 115 document.body.appendChild(testElement);
118 }); 116 });
119 117
120 test('empty state', function() { 118 test('empty state', function() {
121 var category = settings.ContentSettingsTypes.NOTIFICATIONS; 119 var category = settings.ContentSettingsTypes.NOTIFICATIONS;
122 var site = { 120 var site = {
123 origin: 'http://www.google.com', 121 origin: 'http://www.google.com',
124 displayName: 'http://www.google.com', 122 displayName: 'http://www.google.com',
125 embeddingOrigin: '', 123 embeddingOrigin: '',
126 }; 124 };
127 browserProxy.setPrefs(prefsEmpty); 125 browserProxy.setPrefs(prefsEmpty);
128 testElement.category = category; 126 testElement.category = category;
129 testElement.site = site 127 testElement.site = site
130 128
131 //expect usage to not be rendered 129 // expect usage to not be rendered
132 assertFalse(!!testElement.$$('#usage')); 130 assertFalse(!!testElement.$$('#usage'));
133 131
134 // TODO(finnur): Check for the Permission heading hiding when no 132 // TODO(finnur): Check for the Permission heading hiding when no
135 // permissions are showing. 133 // permissions are showing.
136 134
137 var msg = 'No category should be showing, height'; 135 var msg = 'No category should be showing, height';
138 assertEquals(0, testElement.$.camera.offsetHeight, msg); 136 assertEquals(0, testElement.$.camera.offsetHeight, msg);
139 assertEquals(0, testElement.$.cookies.offsetHeight, msg); 137 assertEquals(0, testElement.$.cookies.offsetHeight, msg);
140 assertEquals(0, testElement.$.geolocation.offsetHeight, msg); 138 assertEquals(0, testElement.$.geolocation.offsetHeight, msg);
141 assertEquals(0, testElement.$.javascript.offsetHeight, msg); 139 assertEquals(0, testElement.$.javascript.offsetHeight, msg);
142 assertEquals(0, testElement.$.mic.offsetHeight, msg); 140 assertEquals(0, testElement.$.mic.offsetHeight, msg);
143 assertEquals(0, testElement.$.notification.offsetHeight, msg); 141 assertEquals(0, testElement.$.notification.offsetHeight, msg);
144 assertEquals(0, testElement.$.popups.offsetHeight, msg); 142 assertEquals(0, testElement.$.popups.offsetHeight, msg);
145 }); 143 });
146 144
147 test('all categories visible', function() { 145 test('all categories visible', function() {
148 var category = settings.ContentSettingsTypes.NOTIFICATIONS; 146 var category = settings.ContentSettingsTypes.NOTIFICATIONS;
149 var site = { 147 var site = {
150 origin: 'https://foo-allow.com:443', 148 origin: 'https://foo-allow.com:443',
151 displayName: 'https://foo-allow.com:443', 149 displayName: 'https://foo-allow.com:443',
152 embeddingOrigin: '', 150 embeddingOrigin: '',
153 }; 151 };
154 152
155 browserProxy.setPrefs(prefs); 153 browserProxy.setPrefs(prefs);
156 testElement.category = category; 154 testElement.category = category;
157 testElement.site = site; 155 testElement.site = site;
158 156
159 var msg = 'All categories should be showing'; 157 var msg = 'All categories should be showing';
160 assertFalse(testElement.$.camera.hidden, msg); 158 assertFalse(testElement.$.camera.hidden, msg);
161 assertFalse(testElement.$.cookies.hidden, msg); 159 assertFalse(testElement.$.cookies.hidden, msg);
162 assertFalse(testElement.$.geolocation.hidden, msg); 160 assertFalse(testElement.$.geolocation.hidden, msg);
163 assertFalse(testElement.$.javascript.hidden, msg); 161 assertFalse(testElement.$.javascript.hidden, msg);
164 assertFalse(testElement.$.mic.hidden, msg); 162 assertFalse(testElement.$.mic.hidden, msg);
165 assertFalse(testElement.$.notification.hidden, msg); 163 assertFalse(testElement.$.notification.hidden, msg);
166 assertFalse(testElement.$.popups.hidden, msg); 164 assertFalse(testElement.$.popups.hidden, msg);
167 }); 165 });
168 166
169 test('usage heading shows on storage available', function() { 167 test('usage heading shows on storage available', function() {
170 // Remove the current website-usage-private-api element. 168 // Remove the current website-usage-private-api element.
171 var parent = testElement.$.usageApi.parentNode; 169 var parent = testElement.$.usageApi.parentNode;
172 testElement.$.usageApi.remove(); 170 testElement.$.usageApi.remove();
173 171
174 // Replace it with a mock version. 172 // Replace it with a mock version.
175 Polymer({ 173 Polymer({
176 is: 'mock-website-usage-private-api', 174 is: 'mock-website-usage-private-api',
177 175
178 fetchUsageTotal: function(origin) { 176 fetchUsageTotal: function(origin) {
179 testElement.storedData_ = '1 KB'; 177 testElement.storedData_ = '1 KB';
180 }, 178 },
181 }); 179 });
182 var api = document.createElement('mock-website-usage-private-api'); 180 var api = document.createElement('mock-website-usage-private-api');
183 testElement.$.usageApi = api; 181 testElement.$.usageApi = api;
184 Polymer.dom(parent).appendChild(api); 182 Polymer.dom(parent).appendChild(api);
185 183
186 browserProxy.setPrefs(prefs); 184 browserProxy.setPrefs(prefs);
187 testElement.site = { 185 testElement.site = {
188 origin: 'https://foo-allow.com:443', 186 origin: 'https://foo-allow.com:443',
189 displayName: 'https://foo-allow.com:443', 187 displayName: 'https://foo-allow.com:443',
190 embeddingOrigin: '', 188 embeddingOrigin: '',
191 }; 189 };
192 190
193 Polymer.dom.flush(); 191 Polymer.dom.flush();
194 192
195 //expect usage to be rendered 193 // expect usage to be rendered
196 assertTrue(!!testElement.$$('#usage')); 194 assertTrue(!!testElement.$$('#usage'));
197 }); 195 });
198 });
199 }
200 return {
201 registerTests: registerTests,
202 };
203 }); 196 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698