| 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. |
| 11 * @type {SiteSettingsPref} | 11 * @type {SiteSettingsPref} |
| 12 */ | 12 */ |
| 13 var prefs = { | 13 var prefs = { |
| 14 exceptions: { | 14 exceptions: { |
| 15 auto_downloads: [], | 15 auto_downloads: [], |
| 16 background_sync: [], | 16 background_sync: [], |
| 17 camera: [], | 17 camera: [], |
| 18 cookies: [], | 18 cookies: [], |
| 19 geolocation: [ | 19 geolocation: [ |
| 20 { | 20 { |
| 21 category: 'geolocation', | |
| 22 embeddingOrigin: 'https://bar-allow.com:443', | 21 embeddingOrigin: 'https://bar-allow.com:443', |
| 23 origin: 'https://bar-allow.com:443', | 22 origin: 'https://bar-allow.com:443', |
| 24 setting: 'allow', | 23 setting: 'allow', |
| 25 source: 'preference', | 24 source: 'preference', |
| 26 }, | 25 }, |
| 27 { | 26 { |
| 28 category: 'geolocation', | |
| 29 embeddingOrigin: 'https://foo-allow.com:443', | 27 embeddingOrigin: 'https://foo-allow.com:443', |
| 30 origin: 'https://foo-allow.com:443', | 28 origin: 'https://foo-allow.com:443', |
| 31 setting: 'allow', | 29 setting: 'allow', |
| 32 source: 'preference', | 30 source: 'preference', |
| 33 }, | 31 }, |
| 34 { | 32 { |
| 35 category: 'geolocation', | |
| 36 embeddingOrigin: 'https://bar-block.com:443', | 33 embeddingOrigin: 'https://bar-block.com:443', |
| 37 origin: 'https://bar-block.com:443', | 34 origin: 'https://bar-block.com:443', |
| 38 setting: 'block', | 35 setting: 'block', |
| 39 source: 'preference', | 36 source: 'preference', |
| 40 }, | 37 }, |
| 41 { | 38 { |
| 42 category: 'geolocation', | |
| 43 embeddingOrigin: 'https://foo-block.com:443', | 39 embeddingOrigin: 'https://foo-block.com:443', |
| 44 origin: 'https://foo-block.com:443', | 40 origin: 'https://foo-block.com:443', |
| 45 setting: 'block', | 41 setting: 'block', |
| 46 source: 'preference', | 42 source: 'preference', |
| 47 }, | 43 }, |
| 48 ], | 44 ], |
| 49 images: [], | 45 images: [], |
| 50 javascript: [], | 46 javascript: [], |
| 51 mic: [], | 47 mic: [], |
| 52 midiDevices: [], | 48 midiDevices: [], |
| 53 notifications: [], | 49 notifications: [], |
| 54 plugins: [], | 50 plugins: [], |
| 55 protectedContent: [], | 51 protectedContent: [], |
| 56 popups: [], | 52 popups: [], |
| 57 unsandboxed_plugins: [], | 53 unsandboxed_plugins: [], |
| 58 } | 54 } |
| 59 }; | 55 }; |
| 60 | 56 |
| 61 /** | 57 /** |
| 62 * An example of prefs controlleBy policy. | 58 * An example of prefs controlleBy policy. |
| 63 * @type {SiteSettingsPref} | 59 * @type {SiteSettingsPref} |
| 64 */ | 60 */ |
| 65 var prefsControlled = { | 61 var prefsControlled = { |
| 66 exceptions: { | 62 exceptions: { |
| 67 plugins: [ | 63 plugins: [ |
| 68 { | 64 { |
| 69 category: 'plugins', | |
| 70 embeddingOrigin: 'http://foo-block.com', | 65 embeddingOrigin: 'http://foo-block.com', |
| 71 origin: 'http://foo-block.com', | 66 origin: 'http://foo-block.com', |
| 72 setting: 'block', | 67 setting: 'block', |
| 73 source: 'policy', | 68 source: 'policy', |
| 74 }, | 69 }, |
| 75 ] | 70 ] |
| 76 } | 71 } |
| 77 }; | 72 }; |
| 78 | 73 |
| 79 /** | 74 /** |
| 80 * An example pref with mixed schemes (present and absent). | 75 * An example pref with mixed schemes (present and absent). |
| 81 * @type {SiteSettingsPref} | 76 * @type {SiteSettingsPref} |
| 82 */ | 77 */ |
| 83 var prefsMixedSchemes = { | 78 var prefsMixedSchemes = { |
| 84 exceptions: { | 79 exceptions: { |
| 85 geolocation: [ | 80 geolocation: [ |
| 86 { | 81 { |
| 87 category: 'geolocation', | |
| 88 embeddingOrigin: 'https://foo-allow.com', | 82 embeddingOrigin: 'https://foo-allow.com', |
| 89 origin: 'https://foo-allow.com', | 83 origin: 'https://foo-allow.com', |
| 90 setting: 'allow', | 84 setting: 'allow', |
| 91 source: 'preference', | 85 source: 'preference', |
| 92 }, | 86 }, |
| 93 { | 87 { |
| 94 category: 'geolocation', | |
| 95 embeddingOrigin: 'bar-allow.com', | 88 embeddingOrigin: 'bar-allow.com', |
| 96 origin: 'bar-allow.com', | 89 origin: 'bar-allow.com', |
| 97 setting: 'allow', | 90 setting: 'allow', |
| 98 source: 'preference', | 91 source: 'preference', |
| 99 }, | 92 }, |
| 100 ] | 93 ] |
| 101 } | 94 } |
| 102 }; | 95 }; |
| 103 | 96 |
| 104 | 97 |
| 105 /** | 98 /** |
| 106 * An example pref with exceptions with origins and patterns from | 99 * An example pref with exceptions with origins and patterns from |
| 107 * different providers. | 100 * different providers. |
| 108 * @type {SiteSettingsPref} | 101 * @type {SiteSettingsPref} |
| 109 */ | 102 */ |
| 110 var prefsMixedProvider = { | 103 var prefsMixedProvider = { |
| 111 exceptions: { | 104 exceptions: { |
| 112 geolocation: [ | 105 geolocation: [ |
| 113 { | 106 { |
| 114 category: 'geolocation', | |
| 115 embeddingOrigin: 'https://[*.]foo.com', | 107 embeddingOrigin: 'https://[*.]foo.com', |
| 116 origin: 'https://[*.]foo.com', | 108 origin: 'https://[*.]foo.com', |
| 117 setting: 'block', | 109 setting: 'block', |
| 118 source: 'policy', | 110 source: 'policy', |
| 119 }, | 111 }, |
| 120 { | 112 { |
| 121 category: 'geolocation', | |
| 122 embeddingOrigin: 'https://bar.foo.com', | 113 embeddingOrigin: 'https://bar.foo.com', |
| 123 origin: 'https://bar.foo.com', | 114 origin: 'https://bar.foo.com', |
| 124 setting: 'block', | 115 setting: 'block', |
| 125 source: 'preference', | 116 source: 'preference', |
| 126 }, | 117 }, |
| 127 { | 118 { |
| 128 category: 'geolocation', | |
| 129 embeddingOrigin: 'https://[*.]foo.com', | 119 embeddingOrigin: 'https://[*.]foo.com', |
| 130 origin: 'https://[*.]foo.com', | 120 origin: 'https://[*.]foo.com', |
| 131 setting: 'block', | 121 setting: 'block', |
| 132 source: 'preference', | 122 source: 'preference', |
| 133 }, | 123 }, |
| 134 ] | 124 ] |
| 135 } | 125 } |
| 136 }; | 126 }; |
| 137 | 127 |
| 138 /** | 128 /** |
| 139 * An example pref with mixed origin and pattern. | 129 * An example pref with mixed origin and pattern. |
| 140 * @type {SiteSettingsPref} | 130 * @type {SiteSettingsPref} |
| 141 */ | 131 */ |
| 142 var prefsMixedOriginAndPattern = { | 132 var prefsMixedOriginAndPattern = { |
| 143 exceptions: { | 133 exceptions: { |
| 144 auto_downloads: [], | 134 auto_downloads: [], |
| 145 background_sync: [], | 135 background_sync: [], |
| 146 camera: [], | 136 camera: [], |
| 147 cookies: [], | 137 cookies: [], |
| 148 geolocation: [ | 138 geolocation: [ |
| 149 { | 139 { |
| 150 category: 'geolocation', | |
| 151 origin: 'https://foo.com', | 140 origin: 'https://foo.com', |
| 152 embeddingOrigin: '*', | 141 embeddingOrigin: '*', |
| 153 setting: 'allow', | 142 setting: 'allow', |
| 154 source: 'preference', | 143 source: 'preference', |
| 155 }, | 144 }, |
| 156 ], | 145 ], |
| 157 images: [], | 146 images: [], |
| 158 javascript: [ | 147 javascript: [ |
| 159 { | 148 { |
| 160 category: 'javascript', | |
| 161 origin: 'https://[*.]foo.com', | 149 origin: 'https://[*.]foo.com', |
| 162 embeddingOrigin: '*', | 150 embeddingOrigin: '*', |
| 163 setting: 'allow', | 151 setting: 'allow', |
| 164 source: 'preference', | 152 source: 'preference', |
| 165 }, | 153 }, |
| 166 ], | 154 ], |
| 167 mic: [], | 155 mic: [], |
| 168 notifications: [], | 156 notifications: [], |
| 169 plugins: [], | 157 plugins: [], |
| 170 midiDevices: [], | 158 midiDevices: [], |
| 171 protectedContent: [], | 159 protectedContent: [], |
| 172 popups: [], | 160 popups: [], |
| 173 unsandboxed_plugins: [], | 161 unsandboxed_plugins: [], |
| 174 } | 162 } |
| 175 }; | 163 }; |
| 176 | 164 |
| 177 /** | 165 /** |
| 178 * An example pref with multiple categories and multiple allow/block | 166 * An example pref with multiple categories and multiple allow/block |
| 179 * state. | 167 * state. |
| 180 * @type {SiteSettingsPref} | 168 * @type {SiteSettingsPref} |
| 181 */ | 169 */ |
| 182 var prefsVarious = { | 170 var prefsVarious = { |
| 183 exceptions: { | 171 exceptions: { |
| 184 auto_downloads: [], | 172 auto_downloads: [], |
| 185 background_sync: [], | 173 background_sync: [], |
| 186 camera: [], | 174 camera: [], |
| 187 cookies: [], | 175 cookies: [], |
| 188 geolocation: [ | 176 geolocation: [ |
| 189 { | 177 { |
| 190 category: 'geolocation', | |
| 191 embeddingOrigin: 'https://foo.com', | 178 embeddingOrigin: 'https://foo.com', |
| 192 incognito: false, | 179 incognito: false, |
| 193 origin: 'https://foo.com', | 180 origin: 'https://foo.com', |
| 194 setting: 'allow', | 181 setting: 'allow', |
| 195 source: 'preference', | 182 source: 'preference', |
| 196 }, | 183 }, |
| 197 { | 184 { |
| 198 category: 'geolocation', | |
| 199 embeddingOrigin: 'https://bar.com', | 185 embeddingOrigin: 'https://bar.com', |
| 200 incognito: false, | 186 incognito: false, |
| 201 origin: 'https://bar.com', | 187 origin: 'https://bar.com', |
| 202 setting: 'block', | 188 setting: 'block', |
| 203 source: 'preference', | 189 source: 'preference', |
| 204 }, | 190 }, |
| 205 ], | 191 ], |
| 206 images: [], | 192 images: [], |
| 207 javascript: [], | 193 javascript: [], |
| 208 mic: [], | 194 mic: [], |
| 209 midiDevices: [], | 195 midiDevices: [], |
| 210 notifications: [ | 196 notifications: [ |
| 211 { | 197 { |
| 212 category: 'notifications', | |
| 213 embeddingOrigin: 'https://google.com', | 198 embeddingOrigin: 'https://google.com', |
| 214 incognito: false, | 199 incognito: false, |
| 215 origin: 'https://google.com', | 200 origin: 'https://google.com', |
| 216 setting: 'block', | 201 setting: 'block', |
| 217 source: 'preference', | 202 source: 'preference', |
| 218 }, | 203 }, |
| 219 { | 204 { |
| 220 category: 'notifications', | |
| 221 embeddingOrigin: 'https://bar.com', | 205 embeddingOrigin: 'https://bar.com', |
| 222 incognito: false, | 206 incognito: false, |
| 223 origin: 'https://bar.com', | 207 origin: 'https://bar.com', |
| 224 setting: 'block', | 208 setting: 'block', |
| 225 source: 'preference', | 209 source: 'preference', |
| 226 }, | 210 }, |
| 227 { | 211 { |
| 228 category: 'notifications', | |
| 229 embeddingOrigin: 'https://foo.com', | 212 embeddingOrigin: 'https://foo.com', |
| 230 incognito: false, | 213 incognito: false, |
| 231 origin: 'https://foo.com', | 214 origin: 'https://foo.com', |
| 232 setting: 'block', | 215 setting: 'block', |
| 233 source: 'preference', | 216 source: 'preference', |
| 234 }, | 217 }, |
| 235 ], | 218 ], |
| 236 plugins: [], | 219 plugins: [], |
| 237 protectedContent: [], | 220 protectedContent: [], |
| 238 popups: [], | 221 popups: [], |
| 239 unsandboxed_plugins: [], | 222 unsandboxed_plugins: [], |
| 240 } | 223 } |
| 241 }; | 224 }; |
| 242 | 225 |
| 243 /** | 226 /** |
| 244 * An example pref with 1 allowed location item. | 227 * An example pref with 1 allowed location item. |
| 245 * @type {SiteSettingsPref} | 228 * @type {SiteSettingsPref} |
| 246 */ | 229 */ |
| 247 var prefsOneEnabled = { | 230 var prefsOneEnabled = { |
| 248 exceptions: { | 231 exceptions: { |
| 249 geolocation: [ | 232 geolocation: [ |
| 250 { | 233 { |
| 251 category: 'geolocation', | |
| 252 embeddingOrigin: 'https://foo-allow.com:443', | 234 embeddingOrigin: 'https://foo-allow.com:443', |
| 253 incognito: false, | 235 incognito: false, |
| 254 origin: 'https://foo-allow.com:443', | 236 origin: 'https://foo-allow.com:443', |
| 255 setting: 'allow', | 237 setting: 'allow', |
| 256 source: 'preference', | 238 source: 'preference', |
| 257 }, | 239 }, |
| 258 ] | 240 ] |
| 259 } | 241 } |
| 260 }; | 242 }; |
| 261 | 243 |
| 262 /** | 244 /** |
| 263 * An example pref with 1 blocked location item. | 245 * An example pref with 1 blocked location item. |
| 264 * @type {SiteSettingsPref} | 246 * @type {SiteSettingsPref} |
| 265 */ | 247 */ |
| 266 var prefsOneDisabled = { | 248 var prefsOneDisabled = { |
| 267 exceptions: { | 249 exceptions: { |
| 268 geolocation: [ | 250 geolocation: [ |
| 269 { | 251 { |
| 270 category: 'geolocation', | |
| 271 embeddingOrigin: 'https://foo-block.com:443', | 252 embeddingOrigin: 'https://foo-block.com:443', |
| 272 incognito: false, | 253 incognito: false, |
| 273 origin: 'https://foo-block.com:443', | 254 origin: 'https://foo-block.com:443', |
| 274 setting: 'block', | 255 setting: 'block', |
| 275 source: 'preference', | 256 source: 'preference', |
| 276 }, | 257 }, |
| 277 ] | 258 ] |
| 278 } | 259 } |
| 279 }; | 260 }; |
| 280 | 261 |
| 281 /** | 262 /** |
| 282 * An example Cookies pref with 1 in each of the three categories. | 263 * An example Cookies pref with 1 in each of the three categories. |
| 283 * @type {SiteSettingsPref} | 264 * @type {SiteSettingsPref} |
| 284 */ | 265 */ |
| 285 var prefsSessionOnly = { | 266 var prefsSessionOnly = { |
| 286 exceptions: { | 267 exceptions: { |
| 287 cookies: [ | 268 cookies: [ |
| 288 { | 269 { |
| 289 category: 'cookies', | |
| 290 embeddingOrigin: 'http://foo-block.com', | 270 embeddingOrigin: 'http://foo-block.com', |
| 291 incognito: false, | 271 incognito: false, |
| 292 origin: 'http://foo-block.com', | 272 origin: 'http://foo-block.com', |
| 293 setting: 'block', | 273 setting: 'block', |
| 294 source: 'preference', | 274 source: 'preference', |
| 295 }, | 275 }, |
| 296 { | 276 { |
| 297 category: 'cookies', | |
| 298 embeddingOrigin: 'http://foo-allow.com', | 277 embeddingOrigin: 'http://foo-allow.com', |
| 299 incognito: false, | 278 incognito: false, |
| 300 origin: 'http://foo-allow.com', | 279 origin: 'http://foo-allow.com', |
| 301 setting: 'allow', | 280 setting: 'allow', |
| 302 source: 'preference', | 281 source: 'preference', |
| 303 }, | 282 }, |
| 304 { | 283 { |
| 305 category: 'cookies', | |
| 306 embeddingOrigin: 'http://foo-session.com', | 284 embeddingOrigin: 'http://foo-session.com', |
| 307 incognito: false, | 285 incognito: false, |
| 308 origin: 'http://foo-session.com', | 286 origin: 'http://foo-session.com', |
| 309 setting: 'session_only', | 287 setting: 'session_only', |
| 310 source: 'preference', | 288 source: 'preference', |
| 311 }, | 289 }, |
| 312 ] | 290 ] |
| 313 } | 291 } |
| 314 }; | 292 }; |
| 315 | 293 |
| 316 /** | 294 /** |
| 317 * An example Cookies pref with mixed incognito and regular settings. | 295 * An example Cookies pref with mixed incognito and regular settings. |
| 318 * @type {SiteSettingsPref} | 296 * @type {SiteSettingsPref} |
| 319 */ | 297 */ |
| 320 var prefsIncognito = { | 298 var prefsIncognito = { |
| 321 exceptions: { | 299 exceptions: { |
| 322 cookies: [ | 300 cookies: [ |
| 323 // foo.com is blocked for regular sessions. | 301 // foo.com is blocked for regular sessions. |
| 324 { | 302 { |
| 325 category: 'cookies', | |
| 326 embeddingOrigin: 'http://foo.com', | 303 embeddingOrigin: 'http://foo.com', |
| 327 incognito: false, | 304 incognito: false, |
| 328 origin: 'http://foo.com', | 305 origin: 'http://foo.com', |
| 329 setting: 'block', | 306 setting: 'block', |
| 330 source: 'preference', | 307 source: 'preference', |
| 331 }, | 308 }, |
| 332 // bar.com is an allowed incognito item without an embedder. | 309 // bar.com is an allowed incognito item without an embedder. |
| 333 { | 310 { |
| 334 category: 'cookies', | |
| 335 embeddingOrigin: '', | 311 embeddingOrigin: '', |
| 336 incognito: true, | 312 incognito: true, |
| 337 origin: 'http://bar.com', | 313 origin: 'http://bar.com', |
| 338 setting: 'allow', | 314 setting: 'allow', |
| 339 source: 'preference', | 315 source: 'preference', |
| 340 }, | 316 }, |
| 341 // foo.com is allowed in incognito (overridden). | 317 // foo.com is allowed in incognito (overridden). |
| 342 { | 318 { |
| 343 category: 'cookies', | |
| 344 embeddingOrigin: 'http://foo.com', | 319 embeddingOrigin: 'http://foo.com', |
| 345 incognito: true, | 320 incognito: true, |
| 346 origin: 'http://foo.com', | 321 origin: 'http://foo.com', |
| 347 setting: 'allow', | 322 setting: 'allow', |
| 348 source: 'preference', | 323 source: 'preference', |
| 349 }, | 324 }, |
| 350 | 325 |
| 351 ] | 326 ] |
| 352 } | 327 } |
| 353 }; | 328 }; |
| 354 | 329 |
| 355 /** | 330 /** |
| 356 * An example Javascript pref with a chrome-extension:// scheme. | 331 * An example Javascript pref with a chrome-extension:// scheme. |
| 357 * @type {SiteSettingsPref} | 332 * @type {SiteSettingsPref} |
| 358 */ | 333 */ |
| 359 var prefsChromeExtension = { | 334 var prefsChromeExtension = { |
| 360 exceptions: { | 335 exceptions: { |
| 361 javascript: [ | 336 javascript: [ |
| 362 { | 337 { |
| 363 category: 'javascript', | |
| 364 embeddingOrigin: '', | 338 embeddingOrigin: '', |
| 365 incognito: false, | 339 incognito: false, |
| 366 origin: 'chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/', | 340 origin: 'chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/', |
| 367 setting: 'block', | 341 setting: 'block', |
| 368 source: 'preference', | 342 source: 'preference', |
| 369 }, | 343 }, |
| 370 ] | 344 ] |
| 371 } | 345 } |
| 372 }; | 346 }; |
| 373 | 347 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 return browserProxy.whenCalled('getExceptionList'); | 542 return browserProxy.whenCalled('getExceptionList'); |
| 569 }).then(function() { | 543 }).then(function() { |
| 570 // Check that the action menu was closed. | 544 // Check that the action menu was closed. |
| 571 assertFalse(actionMenu.open); | 545 assertFalse(actionMenu.open); |
| 572 }); | 546 }); |
| 573 }); | 547 }); |
| 574 | 548 |
| 575 test('exceptions are not reordered in non-ALL_SITES', function() { | 549 test('exceptions are not reordered in non-ALL_SITES', function() { |
| 576 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, | 550 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 577 settings.PermissionValues.BLOCK, prefsMixedProvider); | 551 settings.PermissionValues.BLOCK, prefsMixedProvider); |
| 578 return browserProxy.whenCalled('getExceptionList').then( | 552 return browserProxy.whenCalled('getExceptionList') |
| 579 function(contentType) { | 553 .then(function(contentType) { |
| 580 assertEquals( | 554 assertEquals( |
| 581 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 555 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 582 | 556 |
| 583 assertEquals(3, testElement.sites.length); | 557 assertEquals(3, testElement.sites.length); |
| 584 for(var i = 0; i < 3; i++) { | 558 for(var i = 0; i < 3; i++) { |
| 585 assertEquals( | 559 assertEquals( |
| 586 prefsMixedProvider.exceptions.geolocation[0].origin, | 560 prefsMixedProvider.exceptions.geolocation[0].origin, |
| 587 testElement.sites[0].origin); | 561 testElement.sites[0].origin); |
| 588 assertEquals( | 562 assertEquals( |
| 589 prefsMixedProvider.exceptions.geolocation[0].source, | 563 kControlledByLookup |
| 590 testElement.sites[0].source); | 564 [prefsMixedProvider.exceptions.geolocation[0].source], |
| 565 testElement.sites[0].controlledBy); |
| 591 } | 566 } |
| 592 }); | 567 }); |
| 593 }); | 568 }); |
| 594 | 569 |
| 595 test('initial BLOCK state is correct', function() { | 570 test('initial BLOCK state is correct', function() { |
| 596 var contentType = settings.ContentSettingsTypes.GEOLOCATION; | 571 var contentType = settings.ContentSettingsTypes.GEOLOCATION; |
| 597 var categorySubtype = settings.PermissionValues.BLOCK; | 572 var categorySubtype = settings.PermissionValues.BLOCK; |
| 598 setUpCategory(contentType, categorySubtype, prefs); | 573 setUpCategory(contentType, categorySubtype, prefs); |
| 599 return browserProxy.whenCalled('getExceptionList').then( | 574 return browserProxy.whenCalled('getExceptionList').then( |
| 600 function(actualContentType) { | 575 function(actualContentType) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 assertEquals('', args[1]); | 1050 assertEquals('', args[1]); |
| 1076 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); | 1051 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); |
| 1077 assertEquals('allow', args[3]); | 1052 assertEquals('allow', args[3]); |
| 1078 }); | 1053 }); |
| 1079 }); | 1054 }); |
| 1080 }); | 1055 }); |
| 1081 } | 1056 } |
| 1082 | 1057 |
| 1083 suite('EditExceptionDialog', function() { | 1058 suite('EditExceptionDialog', function() { |
| 1084 var dialog; | 1059 var dialog; |
| 1085 var cookieException = prefsIncognito.exceptions.cookies[0]; | 1060 /** |
| 1061 * The dialog tests don't call |getExceptionList| so the exception needs to |
| 1062 * be processes as a |SiteSettingsPref|. |
| 1063 * @type {SiteSettingsPref} |
| 1064 */ |
| 1065 var cookieException = { |
| 1066 category: 'cookies', |
| 1067 embeddingOrigin: 'http://foo.com', |
| 1068 incognito: false, |
| 1069 origin: 'http://foo.com', |
| 1070 setting: 'block', |
| 1071 enforcement: '', |
| 1072 controlledBy: 'USER_POLICY', |
| 1073 }; |
| 1086 | 1074 |
| 1087 setup(function() { | 1075 setup(function() { |
| 1088 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); | 1076 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); |
| 1089 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; | 1077 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; |
| 1090 PolymerTest.clearBody(); | 1078 PolymerTest.clearBody(); |
| 1091 dialog = document.createElement('settings-edit-exception-dialog'); | 1079 dialog = document.createElement('settings-edit-exception-dialog'); |
| 1092 dialog.model = cookieException; | 1080 dialog.model = cookieException; |
| 1093 document.body.appendChild(dialog); | 1081 document.body.appendChild(dialog); |
| 1094 }); | 1082 }); |
| 1095 | 1083 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1121 assertTrue(!!input); | 1109 assertTrue(!!input); |
| 1122 // Simulate user edit. | 1110 // Simulate user edit. |
| 1123 var newValue = input.value + ':1234'; | 1111 var newValue = input.value + ':1234'; |
| 1124 input.value = newValue; | 1112 input.value = newValue; |
| 1125 | 1113 |
| 1126 var actionButton = dialog.$.actionButton; | 1114 var actionButton = dialog.$.actionButton; |
| 1127 assertTrue(!!actionButton); | 1115 assertTrue(!!actionButton); |
| 1128 assertFalse(actionButton.disabled); | 1116 assertFalse(actionButton.disabled); |
| 1129 | 1117 |
| 1130 MockInteractions.tap(actionButton); | 1118 MockInteractions.tap(actionButton); |
| 1131 | 1119 return browserProxy.whenCalled('resetCategoryPermissionForOrigin') |
| 1132 return browserProxy.whenCalled('resetCategoryPermissionForOrigin').then( | 1120 .then(function(args) { |
| 1133 function(args) { | |
| 1134 assertEquals(cookieException.origin, args[0]); | 1121 assertEquals(cookieException.origin, args[0]); |
| 1135 assertEquals(cookieException.embeddingOrigin, args[1]); | 1122 assertEquals(cookieException.embeddingOrigin, args[1]); |
| 1136 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); | 1123 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); |
| 1137 assertEquals(cookieException.incognito, args[3]); | 1124 assertEquals(cookieException.incognito, args[3]); |
| 1138 | 1125 |
| 1139 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); | 1126 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); |
| 1140 }).then(function(args) { | 1127 }) |
| 1128 .then(function(args) { |
| 1141 assertEquals(newValue, args[0]); | 1129 assertEquals(newValue, args[0]); |
| 1142 assertEquals(newValue, args[1]); | 1130 assertEquals(newValue, args[1]); |
| 1143 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); | 1131 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); |
| 1144 assertEquals(cookieException.setting, args[3]); | 1132 assertEquals(cookieException.setting, args[3]); |
| 1145 assertEquals(cookieException.incognito, args[4]); | 1133 assertEquals(cookieException.incognito, args[4]); |
| 1146 | 1134 |
| 1147 assertFalse(dialog.$.dialog.open); | 1135 assertFalse(dialog.$.dialog.open); |
| 1148 }); | 1136 }); |
| 1149 }); | 1137 }); |
| 1150 }); | 1138 }); |
| 1151 | 1139 |
| 1152 return { | 1140 return { |
| 1153 registerTests: registerTests, | 1141 registerTests: registerTests, |
| 1154 }; | 1142 }; |
| 1155 }); | 1143 }); |
| OLD | NEW |