| 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 function registerTests() { | 7 function registerTests() { |
| 8 suite('SiteList', function() { | 8 suite('SiteList', function() { |
| 9 /** | 9 /** |
| 10 * A site list element created before each test. | 10 * A site list element created before each test. |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 function(contentType) { | 348 function(contentType) { |
| 349 assertEquals( | 349 assertEquals( |
| 350 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 350 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 351 | 351 |
| 352 assertEquals(2, testElement.sites.length); | 352 assertEquals(2, testElement.sites.length); |
| 353 assertEquals(prefs.exceptions.geolocation[1].origin, | 353 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 354 testElement.sites[0].origin); | 354 testElement.sites[0].origin); |
| 355 assertEquals( | 355 assertEquals( |
| 356 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 356 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 357 Polymer.dom.flush(); // Populates action menu. | 357 Polymer.dom.flush(); // Populates action menu. |
| 358 assertMenu(['Block', 'Reset to ask'], testElement); | 358 assertMenu(['Block', 'Remove'], testElement); |
| 359 assertEquals('Allow - 2', testElement.$.header.innerText.trim()); | 359 assertEquals('Allow - 2', testElement.$.header.innerText.trim()); |
| 360 | 360 |
| 361 // Site list should show, no matter what category default is set | 361 // Site list should show, no matter what category default is set |
| 362 // to. | 362 // to. |
| 363 assertFalse(testElement.$.category.hidden); | 363 assertFalse(testElement.$.category.hidden); |
| 364 browserProxy.resetResolver('getExceptionList'); | 364 browserProxy.resetResolver('getExceptionList'); |
| 365 testElement.categoryEnabled = false; | 365 testElement.categoryEnabled = false; |
| 366 return browserProxy.whenCalled('getExceptionList'); | 366 return browserProxy.whenCalled('getExceptionList'); |
| 367 }).then(function(contentType) { | 367 }).then(function(contentType) { |
| 368 assertFalse(testElement.$.category.hidden); | 368 assertFalse(testElement.$.category.hidden); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 379 assertEquals( | 379 assertEquals( |
| 380 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 380 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 381 | 381 |
| 382 assertEquals(2, testElement.sites.length); | 382 assertEquals(2, testElement.sites.length); |
| 383 assertEquals(prefs.exceptions.geolocation[3].origin, | 383 assertEquals(prefs.exceptions.geolocation[3].origin, |
| 384 testElement.sites[0].origin); | 384 testElement.sites[0].origin); |
| 385 | 385 |
| 386 assertEquals( | 386 assertEquals( |
| 387 settings.PermissionValues.BLOCK, testElement.categorySubtype); | 387 settings.PermissionValues.BLOCK, testElement.categorySubtype); |
| 388 Polymer.dom.flush(); // Populates action menu. | 388 Polymer.dom.flush(); // Populates action menu. |
| 389 assertMenu(['Allow', 'Reset to ask'], testElement); | 389 assertMenu(['Allow', 'Remove'], testElement); |
| 390 assertEquals('Block - 2', testElement.$.header.innerText.trim()); | 390 assertEquals('Block - 2', testElement.$.header.innerText.trim()); |
| 391 | 391 |
| 392 // Site list should only show when category default is enabled. | 392 // Site list should only show when category default is enabled. |
| 393 assertFalse(testElement.$.category.hidden); | 393 assertFalse(testElement.$.category.hidden); |
| 394 browserProxy.resetResolver('getExceptionList'); | 394 browserProxy.resetResolver('getExceptionList'); |
| 395 testElement.categoryEnabled = false; | 395 testElement.categoryEnabled = false; |
| 396 return browserProxy.whenCalled('getExceptionList'); | 396 return browserProxy.whenCalled('getExceptionList'); |
| 397 }).then(function(contentType) { | 397 }).then(function(contentType) { |
| 398 assertTrue(testElement.$.category.hidden); | 398 assertTrue(testElement.$.category.hidden); |
| 399 }); | 399 }); |
| 400 }); | 400 }); |
| 401 | 401 |
| 402 test('initial SESSION ONLY state is correct', function() { | 402 test('initial SESSION ONLY state is correct', function() { |
| 403 setupCategory(settings.ContentSettingsTypes.COOKIES, | 403 setupCategory(settings.ContentSettingsTypes.COOKIES, |
| 404 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); | 404 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); |
| 405 return browserProxy.whenCalled('getExceptionList').then( | 405 return browserProxy.whenCalled('getExceptionList').then( |
| 406 function(contentType) { | 406 function(contentType) { |
| 407 assertEquals( | 407 assertEquals( |
| 408 settings.ContentSettingsTypes.COOKIES, contentType); | 408 settings.ContentSettingsTypes.COOKIES, contentType); |
| 409 | 409 |
| 410 assertEquals(1, testElement.sites.length); | 410 assertEquals(1, testElement.sites.length); |
| 411 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, | 411 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, |
| 412 testElement.sites[0].origin); | 412 testElement.sites[0].origin); |
| 413 | 413 |
| 414 assertEquals(settings.PermissionValues.SESSION_ONLY, | 414 assertEquals(settings.PermissionValues.SESSION_ONLY, |
| 415 testElement.categorySubtype); | 415 testElement.categorySubtype); |
| 416 Polymer.dom.flush(); // Populates action menu. | 416 Polymer.dom.flush(); // Populates action menu. |
| 417 assertMenu(['Allow', 'Block', 'Reset to ask'], testElement); | 417 assertMenu(['Allow', 'Block', 'Remove'], testElement); |
| 418 assertEquals('Clear on exit - 1', | 418 assertEquals('Clear on exit - 1', |
| 419 testElement.$.header.innerText.trim()); | 419 testElement.$.header.innerText.trim()); |
| 420 | 420 |
| 421 // Site list should show, no matter what category default is set | 421 // Site list should show, no matter what category default is set |
| 422 // to. | 422 // to. |
| 423 assertFalse(testElement.$.category.hidden); | 423 assertFalse(testElement.$.category.hidden); |
| 424 browserProxy.resetResolver('getExceptionList'); | 424 browserProxy.resetResolver('getExceptionList'); |
| 425 testElement.categoryEnabled = false; | 425 testElement.categoryEnabled = false; |
| 426 return browserProxy.whenCalled('getExceptionList'); | 426 return browserProxy.whenCalled('getExceptionList'); |
| 427 }).then(function(contentType) { | 427 }).then(function(contentType) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 function(contentType) { | 640 function(contentType) { |
| 641 // No further checks needed. If this fails, it will hang the test. | 641 // No further checks needed. If this fails, it will hang the test. |
| 642 }); | 642 }); |
| 643 }); | 643 }); |
| 644 }); | 644 }); |
| 645 } | 645 } |
| 646 return { | 646 return { |
| 647 registerTests: registerTests, | 647 registerTests: registerTests, |
| 648 }; | 648 }; |
| 649 }); | 649 }); |
| OLD | NEW |