Chromium Code Reviews| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 */ | 357 */ |
| 358 function assertMenu(items) { | 358 function assertMenu(items) { |
| 359 var menuItems = getMenuItems(); | 359 var menuItems = getMenuItems(); |
| 360 assertEquals(items.length, menuItems.length); | 360 assertEquals(items.length, menuItems.length); |
| 361 for (var i = 0; i < items.length; i++) | 361 for (var i = 0; i < items.length; i++) |
| 362 assertEquals(items[i], menuItems[i].textContent.trim()); | 362 assertEquals(items[i], menuItems[i].textContent.trim()); |
| 363 } | 363 } |
| 364 | 364 |
| 365 /** | 365 /** |
| 366 * Configures the test element for a particular category. | 366 * Configures the test element for a particular category. |
| 367 * @param {settings.ContentSettingsTypes} category The category to setup. | 367 * @param {settings.ContentSettingsTypes} category The category to set up. |
| 368 * @param {settings.PermissionValues} subtype Type of list to use. | 368 * @param {settings.PermissionValues} subtype Type of list to use. |
| 369 * @param {Array<dictionary>} prefs The prefs to use. | 369 * @param {Array<dictionary>} prefs The prefs to use. |
| 370 */ | 370 */ |
| 371 function setupCategory(category, subtype, prefs) { | 371 function setUpCategory(category, subtype, prefs) { |
| 372 browserProxy.setPrefs(prefs); | 372 browserProxy.setPrefs(prefs); |
| 373 if (category == settings.ALL_SITES) { | 373 if (category == settings.ALL_SITES) { |
| 374 testElement.categorySubtype = settings.INVALID_CATEGORY_SUBTYPE; | 374 testElement.categorySubtype = settings.INVALID_CATEGORY_SUBTYPE; |
| 375 testElement.allSites = true; | 375 testElement.allSites = true; |
| 376 } else { | 376 } else { |
| 377 testElement.categorySubtype = subtype; | 377 testElement.categorySubtype = subtype; |
| 378 testElement.allSites = false; | 378 testElement.allSites = false; |
| 379 } | 379 } |
| 380 // Some route is needed, but the actual route doesn't matter. | 380 // Some route is needed, but the actual route doesn't matter. |
| 381 testElement.currentRoute = { | 381 testElement.currentRoute = { |
| 382 page: 'dummy', | 382 page: 'dummy', |
| 383 section: 'privacy', | 383 section: 'privacy', |
| 384 subpage: ['site-settings', 'site-settings-category-location'], | 384 subpage: ['site-settings', 'site-settings-category-location'], |
| 385 }; | 385 }; |
| 386 testElement.category = category; | 386 testElement.category = category; |
| 387 } | 387 } |
| 388 | 388 |
| 389 test('getExceptionList API used', function() { | 389 test('getExceptionList API used', function() { |
| 390 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 390 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 391 settings.PermissionValues.ALLOW, prefsEmpty); | 391 settings.PermissionValues.ALLOW, prefsEmpty); |
| 392 return browserProxy.whenCalled('getExceptionList').then( | 392 return browserProxy.whenCalled('getExceptionList').then( |
| 393 function(contentType) { | 393 function(contentType) { |
| 394 assertEquals( | 394 assertEquals( |
| 395 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 395 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 396 }); | 396 }); |
| 397 }); | 397 }); |
| 398 | 398 |
| 399 test('Empty list', function() { | 399 test('Empty list', function() { |
| 400 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 400 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 401 settings.PermissionValues.ALLOW, prefsEmpty); | 401 settings.PermissionValues.ALLOW, prefsEmpty); |
| 402 return browserProxy.whenCalled('getExceptionList').then( | 402 return browserProxy.whenCalled('getExceptionList').then( |
| 403 function(contentType) { | 403 function(contentType) { |
| 404 assertEquals( | 404 assertEquals( |
| 405 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 405 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 406 | 406 |
| 407 assertEquals(0, testElement.sites.length); | 407 assertEquals(0, testElement.sites.length); |
| 408 | 408 |
| 409 assertEquals( | 409 assertEquals( |
| 410 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 410 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 411 | 411 |
| 412 assertFalse(testElement.$.category.hidden); | 412 assertFalse(testElement.$.category.hidden); |
| 413 browserProxy.resetResolver('getExceptionList'); | |
| 414 testElement.categoryEnabled = false; | |
| 415 return browserProxy.whenCalled('getExceptionList'); | |
| 416 }).then(function(contentType) { | |
| 417 assertFalse(testElement.$.category.hidden); | |
| 418 }); | 413 }); |
| 419 }); | 414 }); |
| 420 | 415 |
| 421 test('initial ALLOW state is correct', function() { | 416 test('initial ALLOW state is correct', function() { |
| 422 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 417 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 423 settings.PermissionValues.ALLOW, prefs); | 418 settings.PermissionValues.ALLOW, prefs); |
| 424 return browserProxy.whenCalled('getExceptionList').then( | 419 return browserProxy.whenCalled('getExceptionList').then( |
| 425 function(contentType) { | 420 function(contentType) { |
| 426 assertEquals( | 421 assertEquals( |
| 427 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 422 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 428 | 423 |
| 429 assertEquals(2, testElement.sites.length); | 424 assertEquals(2, testElement.sites.length); |
| 430 assertEquals(prefs.exceptions.geolocation[1].origin, | 425 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 431 testElement.sites[0].origin); | 426 testElement.sites[0].origin); |
| 432 assertEquals( | 427 assertEquals( |
| 433 settings.PermissionValues.ALLOW, testElement.categorySubtype); | 428 settings.PermissionValues.ALLOW, testElement.categorySubtype); |
| 434 Polymer.dom.flush(); // Populates action menu. | 429 Polymer.dom.flush(); // Populates action menu. |
| 435 openActionMenu(0); | 430 openActionMenu(0); |
| 436 assertMenu(['Block', 'Remove'], testElement); | 431 assertMenu(['Block', 'Remove'], testElement); |
| 437 | 432 |
| 438 // Site list should show, no matter what category default is set | |
| 439 // to. | |
| 440 assertFalse(testElement.$.category.hidden); | |
|
dpapad
2016/11/10 22:22:45
Does it still makes sense to assert() for both cat
dschuyler
2016/11/10 22:34:38
I think it made sense to have the prior testing wh
| |
| 441 browserProxy.resetResolver('getExceptionList'); | |
| 442 testElement.categoryEnabled = false; | |
| 443 return browserProxy.whenCalled('getExceptionList'); | |
| 444 }).then(function(contentType) { | |
| 445 assertFalse(testElement.$.category.hidden); | 433 assertFalse(testElement.$.category.hidden); |
| 446 }); | 434 }); |
| 447 }); | 435 }); |
| 448 | 436 |
| 449 test('initial BLOCK state is correct', function() { | 437 test('initial BLOCK state is correct', function() { |
| 450 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 438 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 451 settings.PermissionValues.BLOCK, prefs); | 439 settings.PermissionValues.BLOCK, prefs); |
| 452 return browserProxy.whenCalled('getExceptionList').then( | 440 return browserProxy.whenCalled('getExceptionList').then( |
| 453 function(contentType) { | 441 function(contentType) { |
| 454 assertEquals( | 442 assertEquals( |
| 455 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 443 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 456 | 444 |
| 457 assertEquals(2, testElement.sites.length); | 445 assertEquals(2, testElement.sites.length); |
| 458 assertEquals(prefs.exceptions.geolocation[3].origin, | 446 assertEquals(prefs.exceptions.geolocation[3].origin, |
| 459 testElement.sites[0].origin); | 447 testElement.sites[0].origin); |
| 460 | 448 |
| 461 assertEquals( | 449 assertEquals( |
| 462 settings.PermissionValues.BLOCK, testElement.categorySubtype); | 450 settings.PermissionValues.BLOCK, testElement.categorySubtype); |
| 463 Polymer.dom.flush(); // Populates action menu. | 451 Polymer.dom.flush(); // Populates action menu. |
| 464 openActionMenu(0); | 452 openActionMenu(0); |
| 465 assertMenu(['Allow', 'Remove'], testElement); | 453 assertMenu(['Allow', 'Remove'], testElement); |
| 466 | 454 |
| 467 // Site list should only show when category default is enabled. | |
| 468 assertFalse(testElement.$.category.hidden); | 455 assertFalse(testElement.$.category.hidden); |
| 469 browserProxy.resetResolver('getExceptionList'); | |
| 470 testElement.categoryEnabled = false; | |
| 471 return browserProxy.whenCalled('getExceptionList'); | |
| 472 }).then(function(contentType) { | |
| 473 assertTrue(testElement.$.category.hidden); | |
| 474 }); | 456 }); |
| 475 }); | 457 }); |
| 476 | 458 |
| 477 test('initial SESSION ONLY state is correct', function() { | 459 test('initial SESSION ONLY state is correct', function() { |
| 478 setupCategory(settings.ContentSettingsTypes.COOKIES, | 460 setUpCategory(settings.ContentSettingsTypes.COOKIES, |
| 479 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); | 461 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); |
| 480 return browserProxy.whenCalled('getExceptionList').then( | 462 return browserProxy.whenCalled('getExceptionList').then( |
| 481 function(contentType) { | 463 function(contentType) { |
| 482 assertEquals( | 464 assertEquals( |
| 483 settings.ContentSettingsTypes.COOKIES, contentType); | 465 settings.ContentSettingsTypes.COOKIES, contentType); |
| 484 | 466 |
| 485 assertEquals(1, testElement.sites.length); | 467 assertEquals(1, testElement.sites.length); |
| 486 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, | 468 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, |
| 487 testElement.sites[0].origin); | 469 testElement.sites[0].origin); |
| 488 | 470 |
| 489 assertEquals(settings.PermissionValues.SESSION_ONLY, | 471 assertEquals(settings.PermissionValues.SESSION_ONLY, |
| 490 testElement.categorySubtype); | 472 testElement.categorySubtype); |
| 491 Polymer.dom.flush(); // Populates action menu. | 473 Polymer.dom.flush(); // Populates action menu. |
| 492 openActionMenu(0); | 474 openActionMenu(0); |
| 493 assertMenu(['Allow', 'Block', 'Remove'], testElement); | 475 assertMenu(['Allow', 'Block', 'Remove'], testElement); |
| 494 | 476 |
| 495 // Site list should show, no matter what category default is set | |
| 496 // to. | |
| 497 assertFalse(testElement.$.category.hidden); | |
| 498 browserProxy.resetResolver('getExceptionList'); | |
| 499 testElement.categoryEnabled = false; | |
| 500 return browserProxy.whenCalled('getExceptionList'); | |
| 501 }).then(function(contentType) { | |
| 502 assertFalse(testElement.$.category.hidden); | 477 assertFalse(testElement.$.category.hidden); |
| 503 }); | 478 }); |
| 504 }); | 479 }); |
| 505 | 480 |
| 506 test('initial INCOGNITO BLOCK state is correct', function() { | 481 test('initial INCOGNITO BLOCK state is correct', function() { |
| 507 setupCategory(settings.ContentSettingsTypes.COOKIES, | 482 setUpCategory(settings.ContentSettingsTypes.COOKIES, |
| 508 settings.PermissionValues.BLOCK, prefsIncognito); | 483 settings.PermissionValues.BLOCK, prefsIncognito); |
| 509 return browserProxy.whenCalled('getExceptionList').then( | 484 return browserProxy.whenCalled('getExceptionList').then( |
| 510 function(contentType) { | 485 function(contentType) { |
| 511 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType); | 486 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType); |
| 512 | 487 |
| 513 assertEquals(1, testElement.sites.length); | 488 assertEquals(1, testElement.sites.length); |
| 514 assertEquals(prefsIncognito.exceptions.cookies[0].origin, | 489 assertEquals(prefsIncognito.exceptions.cookies[0].origin, |
| 515 testElement.sites[0].origin); | 490 testElement.sites[0].origin); |
| 516 | 491 |
| 517 assertEquals(settings.PermissionValues.BLOCK, | 492 assertEquals(settings.PermissionValues.BLOCK, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 529 'resetCategoryPermissionForOrigin'); | 504 'resetCategoryPermissionForOrigin'); |
| 530 }).then(function(args) { | 505 }).then(function(args) { |
| 531 assertEquals('http://foo.com', args[0]); | 506 assertEquals('http://foo.com', args[0]); |
| 532 assertEquals('http://foo.com', args[1]); | 507 assertEquals('http://foo.com', args[1]); |
| 533 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); | 508 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); |
| 534 assertFalse(args[3]); // Incognito. | 509 assertFalse(args[3]); // Incognito. |
| 535 }); | 510 }); |
| 536 }); | 511 }); |
| 537 | 512 |
| 538 test('initial INCOGNITO ALLOW state is correct', function() { | 513 test('initial INCOGNITO ALLOW state is correct', function() { |
| 539 setupCategory(settings.ContentSettingsTypes.COOKIES, | 514 setUpCategory(settings.ContentSettingsTypes.COOKIES, |
| 540 settings.PermissionValues.ALLOW, prefsIncognito); | 515 settings.PermissionValues.ALLOW, prefsIncognito); |
| 541 return browserProxy.whenCalled('getExceptionList').then( | 516 return browserProxy.whenCalled('getExceptionList').then( |
| 542 function(contentType) { | 517 function(contentType) { |
| 543 assertEquals( | 518 assertEquals( |
| 544 settings.ContentSettingsTypes.COOKIES, contentType); | 519 settings.ContentSettingsTypes.COOKIES, contentType); |
| 545 | 520 |
| 546 assertEquals(2, testElement.sites.length); | 521 assertEquals(2, testElement.sites.length); |
| 547 assertEquals(prefsIncognito.exceptions.cookies[2].origin, | 522 assertEquals(prefsIncognito.exceptions.cookies[2].origin, |
| 548 testElement.sites[0].origin); | 523 testElement.sites[0].origin); |
| 549 assertEquals(prefsIncognito.exceptions.cookies[1].origin, | 524 assertEquals(prefsIncognito.exceptions.cookies[1].origin, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 566 'resetCategoryPermissionForOrigin'); | 541 'resetCategoryPermissionForOrigin'); |
| 567 }).then(function(args) { | 542 }).then(function(args) { |
| 568 assertEquals('http://foo.com', args[0]); | 543 assertEquals('http://foo.com', args[0]); |
| 569 assertEquals('http://foo.com', args[1]); | 544 assertEquals('http://foo.com', args[1]); |
| 570 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); | 545 assertEquals(settings.ContentSettingsTypes.COOKIES, args[2]); |
| 571 assertTrue(args[3]); // Incognito. | 546 assertTrue(args[3]); // Incognito. |
| 572 }); | 547 }); |
| 573 }); | 548 }); |
| 574 | 549 |
| 575 test('list items shown and clickable when data is present', function() { | 550 test('list items shown and clickable when data is present', function() { |
| 576 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 551 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 577 settings.PermissionValues.ALLOW, prefs); | 552 settings.PermissionValues.ALLOW, prefs); |
| 578 return browserProxy.whenCalled('getExceptionList').then( | 553 return browserProxy.whenCalled('getExceptionList').then( |
| 579 function(contentType) { | 554 function(contentType) { |
| 580 testElement.enableSiteSettings_ = true; | 555 testElement.enableSiteSettings_ = true; |
| 581 assertEquals( | 556 assertEquals( |
| 582 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 557 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 583 | 558 |
| 584 // Required for firstItem to be found below. | 559 // Required for firstItem to be found below. |
| 585 Polymer.dom.flush(); | 560 Polymer.dom.flush(); |
| 586 | 561 |
| 587 // Validate that the sites gets populated from pre-canned prefs. | 562 // Validate that the sites gets populated from pre-canned prefs. |
| 588 assertEquals(2, testElement.sites.length); | 563 assertEquals(2, testElement.sites.length); |
| 589 assertEquals(prefs.exceptions.geolocation[1].origin, | 564 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 590 testElement.sites[0].origin); | 565 testElement.sites[0].origin); |
| 591 assertEquals(undefined, testElement.selectedOrigin); | 566 assertEquals(undefined, testElement.selectedOrigin); |
| 592 | 567 |
| 593 // Validate that the sites are shown in UI and can be selected. | 568 // Validate that the sites are shown in UI and can be selected. |
| 594 var firstItem = testElement.$.listContainer.children[0]; | 569 var firstItem = testElement.$.listContainer.children[0]; |
| 595 var clickable = firstItem.querySelector('.middle'); | 570 var clickable = firstItem.querySelector('.middle'); |
| 596 assertNotEquals(undefined, clickable); | 571 assertNotEquals(undefined, clickable); |
| 597 MockInteractions.tap(clickable); | 572 MockInteractions.tap(clickable); |
| 598 assertEquals(prefs.exceptions.geolocation[1].origin, | 573 assertEquals(prefs.exceptions.geolocation[1].origin, |
| 599 testElement.selectedSite.origin); | 574 testElement.selectedSite.origin); |
| 600 }); | 575 }); |
| 601 }); | 576 }); |
| 602 | 577 |
| 603 test('Block list open when Allow list is empty', function() { | 578 test('Block list open when Allow list is empty', function() { |
| 604 // Prefs: One item in Block list, nothing in Allow list. | 579 // Prefs: One item in Block list, nothing in Allow list. |
| 605 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 580 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 606 settings.PermissionValues.BLOCK, prefsOneDisabled); | 581 settings.PermissionValues.BLOCK, prefsOneDisabled); |
| 607 return browserProxy.whenCalled('getExceptionList').then( | 582 return browserProxy.whenCalled('getExceptionList').then( |
| 608 function(contentType) { | 583 function(contentType) { |
| 609 assertEquals( | 584 assertEquals( |
| 610 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 585 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 611 assertFalse(testElement.$.category.hidden); | 586 assertFalse(testElement.$.category.hidden); |
| 612 }).then(function() { | 587 }).then(function() { |
| 613 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 588 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 614 }); | 589 }); |
| 615 }); | 590 }); |
| 616 | 591 |
| 617 test('Block list closed when Allow list is not empty', function() { | 592 test('Block list closed when Allow list is not empty', function() { |
| 618 // Prefs: Items in both Block and Allow list. | 593 // Prefs: Items in both Block and Allow list. |
| 619 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 594 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 620 settings.PermissionValues.BLOCK, prefs); | 595 settings.PermissionValues.BLOCK, prefs); |
| 621 return browserProxy.whenCalled('getExceptionList').then( | 596 return browserProxy.whenCalled('getExceptionList').then( |
| 622 function(contentType) { | 597 function(contentType) { |
| 623 assertEquals( | 598 assertEquals( |
| 624 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 599 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 625 assertFalse(testElement.$.category.hidden); | 600 assertFalse(testElement.$.category.hidden); |
| 626 assertEquals(0, testElement.$.listContainer.offsetHeight); | 601 assertEquals(0, testElement.$.listContainer.offsetHeight); |
| 627 }); | 602 }); |
| 628 }); | 603 }); |
| 629 | 604 |
| 630 test('Allow list is always open (Block list empty)', function() { | 605 test('Allow list is always open (Block list empty)', function() { |
| 631 // Prefs: One item in Allow list, nothing in Block list. | 606 // Prefs: One item in Allow list, nothing in Block list. |
| 632 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 607 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 633 settings.PermissionValues.ALLOW, prefsOneEnabled); | 608 settings.PermissionValues.ALLOW, prefsOneEnabled); |
| 634 return browserProxy.whenCalled('getExceptionList').then( | 609 return browserProxy.whenCalled('getExceptionList').then( |
| 635 function(contentType) { | 610 function(contentType) { |
| 636 assertEquals( | 611 assertEquals( |
| 637 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 612 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 638 | 613 |
| 639 assertFalse(testElement.$.category.hidden); | 614 assertFalse(testElement.$.category.hidden); |
| 640 }).then(function() { | 615 }).then(function() { |
| 641 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 616 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 642 }); | 617 }); |
| 643 }); | 618 }); |
| 644 | 619 |
| 645 test('Allow list is always open (Block list non-empty)', function() { | 620 test('Allow list is always open (Block list non-empty)', function() { |
| 646 // Prefs: Items in both Block and Allow list. | 621 // Prefs: Items in both Block and Allow list. |
| 647 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 622 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 648 settings.PermissionValues.ALLOW, prefs); | 623 settings.PermissionValues.ALLOW, prefs); |
| 649 return browserProxy.whenCalled('getExceptionList').then( | 624 return browserProxy.whenCalled('getExceptionList').then( |
| 650 function(contentType) { | 625 function(contentType) { |
| 651 assertEquals( | 626 assertEquals( |
| 652 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 627 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 653 assertFalse(testElement.$.category.hidden); | 628 assertFalse(testElement.$.category.hidden); |
| 654 }).then(function() { | 629 }).then(function() { |
| 655 assertNotEquals(0, testElement.$.listContainer.offsetHeight); | 630 assertNotEquals(0, testElement.$.listContainer.offsetHeight); |
| 656 }); | 631 }); |
| 657 }); | 632 }); |
| 658 | 633 |
| 659 test('Block list not hidden when empty', function() { | 634 test('Block list not hidden when empty', function() { |
| 660 // Prefs: One item in Allow list, nothing in Block list. | 635 // Prefs: One item in Allow list, nothing in Block list. |
| 661 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 636 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 662 settings.PermissionValues.BLOCK, prefsOneEnabled); | 637 settings.PermissionValues.BLOCK, prefsOneEnabled); |
| 663 return browserProxy.whenCalled('getExceptionList').then( | 638 return browserProxy.whenCalled('getExceptionList').then( |
| 664 function(contentType) { | 639 function(contentType) { |
| 665 assertEquals( | 640 assertEquals( |
| 666 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 641 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 667 assertFalse(testElement.$.category.hidden); | 642 assertFalse(testElement.$.category.hidden); |
| 668 }); | 643 }); |
| 669 }); | 644 }); |
| 670 | 645 |
| 671 test('Allow list not hidden when empty', function() { | 646 test('Allow list not hidden when empty', function() { |
| 672 // Prefs: One item in Block list, nothing in Allow list. | 647 // Prefs: One item in Block list, nothing in Allow list. |
| 673 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 648 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 674 settings.PermissionValues.ALLOW, prefsOneDisabled); | 649 settings.PermissionValues.ALLOW, prefsOneDisabled); |
| 675 return browserProxy.whenCalled('getExceptionList').then( | 650 return browserProxy.whenCalled('getExceptionList').then( |
| 676 function(contentType) { | 651 function(contentType) { |
| 677 assertEquals( | 652 assertEquals( |
| 678 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 653 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
| 679 assertFalse(testElement.$.category.hidden); | 654 assertFalse(testElement.$.category.hidden); |
| 680 }); | 655 }); |
| 681 }); | 656 }); |
| 682 | 657 |
| 683 test('All sites category', function() { | 658 test('All sites category', function() { |
| 684 // Prefs: Multiple and overlapping sites. | 659 // Prefs: Multiple and overlapping sites. |
| 685 setupCategory(settings.ALL_SITES, '', prefsVarious); | 660 setUpCategory(settings.ALL_SITES, '', prefsVarious); |
| 686 | 661 |
| 687 return browserProxy.whenCalled('getExceptionList').then( | 662 return browserProxy.whenCalled('getExceptionList').then( |
| 688 function(contentType) { | 663 function(contentType) { |
| 689 // Use resolver to ensure asserts bubble up to the framework with | 664 // Use resolver to ensure asserts bubble up to the framework with |
| 690 // meaningful errors. | 665 // meaningful errors. |
| 691 var resolver = new PromiseResolver(); | 666 var resolver = new PromiseResolver(); |
| 692 testElement.async(resolver.resolve); | 667 testElement.async(resolver.resolve); |
| 693 return resolver.promise.then(function() { | 668 return resolver.promise.then(function() { |
| 694 testElement.enableSiteSettings_ = true; | 669 testElement.enableSiteSettings_ = true; |
| 695 // All Sites calls getExceptionList for all categories, starting | 670 // All Sites calls getExceptionList for all categories, starting |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 719 assertNotEquals(undefined, clickable); | 694 assertNotEquals(undefined, clickable); |
| 720 MockInteractions.tap(clickable); | 695 MockInteractions.tap(clickable); |
| 721 assertEquals(prefsVarious.exceptions.geolocation[0].origin, | 696 assertEquals(prefsVarious.exceptions.geolocation[0].origin, |
| 722 testElement.selectedSite.origin); | 697 testElement.selectedSite.origin); |
| 723 }); | 698 }); |
| 724 }); | 699 }); |
| 725 }); | 700 }); |
| 726 | 701 |
| 727 test('All sites mixed pattern and origin', function() { | 702 test('All sites mixed pattern and origin', function() { |
| 728 // Prefs: One site, represented as origin and pattern. | 703 // Prefs: One site, represented as origin and pattern. |
| 729 setupCategory(settings.ALL_SITES, '', prefsMixedOriginAndPattern); | 704 setUpCategory(settings.ALL_SITES, '', prefsMixedOriginAndPattern); |
| 730 | 705 |
| 731 return browserProxy.whenCalled('getExceptionList').then( | 706 return browserProxy.whenCalled('getExceptionList').then( |
| 732 function(contentType) { | 707 function(contentType) { |
| 733 // Use resolver to ensure asserts bubble up to the framework with | 708 // Use resolver to ensure asserts bubble up to the framework with |
| 734 // meaningful errors. | 709 // meaningful errors. |
| 735 var resolver = new PromiseResolver(); | 710 var resolver = new PromiseResolver(); |
| 736 testElement.async(resolver.resolve); | 711 testElement.async(resolver.resolve); |
| 737 return resolver.promise.then(function() { | 712 return resolver.promise.then(function() { |
| 738 testElement.enableSiteSettings_ = true; | 713 testElement.enableSiteSettings_ = true; |
| 739 // All Sites calls getExceptionList for all categories, starting | 714 // All Sites calls getExceptionList for all categories, starting |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 761 MockInteractions.tap(clickable); | 736 MockInteractions.tap(clickable); |
| 762 assertEquals( | 737 assertEquals( |
| 763 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, | 738 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, |
| 764 testElement.selectedSite.originForDisplay); | 739 testElement.selectedSite.originForDisplay); |
| 765 }); | 740 }); |
| 766 }); | 741 }); |
| 767 }); | 742 }); |
| 768 | 743 |
| 769 test('Mixed schemes (present and absent)', function() { | 744 test('Mixed schemes (present and absent)', function() { |
| 770 // Prefs: One item with scheme and one without. | 745 // Prefs: One item with scheme and one without. |
| 771 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 746 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 772 settings.PermissionValues.ALLOW, prefsMixedSchemes); | 747 settings.PermissionValues.ALLOW, prefsMixedSchemes); |
| 773 return browserProxy.whenCalled('getExceptionList').then( | 748 return browserProxy.whenCalled('getExceptionList').then( |
| 774 function(contentType) { | 749 function(contentType) { |
| 775 // No further checks needed. If this fails, it will hang the test. | 750 // No further checks needed. If this fails, it will hang the test. |
| 776 }); | 751 }); |
| 777 }); | 752 }); |
| 778 | 753 |
| 779 test('Select menu item', function() { | 754 test('Select menu item', function() { |
| 780 // Test for error: "Cannot read property 'origin' of undefined". | 755 // Test for error: "Cannot read property 'origin' of undefined". |
| 781 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, | 756 setUpCategory(settings.ContentSettingsTypes.GEOLOCATION, |
| 782 settings.PermissionValues.ALLOW, prefs); | 757 settings.PermissionValues.ALLOW, prefs); |
| 783 return browserProxy.whenCalled('getExceptionList').then(function( | 758 return browserProxy.whenCalled('getExceptionList').then(function( |
| 784 contentType) { | 759 contentType) { |
| 785 Polymer.dom.flush(); | 760 Polymer.dom.flush(); |
| 786 openActionMenu(0); | 761 openActionMenu(0); |
| 787 var menuItems = getMenuItems(); | 762 var menuItems = getMenuItems(); |
| 788 assertTrue(!!menuItems); | 763 assertTrue(!!menuItems); |
| 789 MockInteractions.tap(menuItems[0]); | 764 MockInteractions.tap(menuItems[0]); |
| 790 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); | 765 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); |
| 791 }); | 766 }); |
| 792 }); | 767 }); |
| 793 | 768 |
| 794 test('Chrome Extension scheme', function() { | 769 test('Chrome Extension scheme', function() { |
| 795 setupCategory(settings.ContentSettingsTypes.JAVASCRIPT, | 770 setUpCategory(settings.ContentSettingsTypes.JAVASCRIPT, |
| 796 settings.PermissionValues.BLOCK, prefsChromeExtension); | 771 settings.PermissionValues.BLOCK, prefsChromeExtension); |
| 797 return browserProxy.whenCalled('getExceptionList').then(function( | 772 return browserProxy.whenCalled('getExceptionList').then(function( |
| 798 contentType) { | 773 contentType) { |
| 799 Polymer.dom.flush(); | 774 Polymer.dom.flush(); |
| 800 openActionMenu(0); | 775 openActionMenu(0); |
| 801 assertMenu(['Allow', 'Remove'], testElement); | 776 assertMenu(['Allow', 'Remove'], testElement); |
| 802 | 777 |
| 803 var menuItems = getMenuItems(); | 778 var menuItems = getMenuItems(); |
| 804 assertTrue(!!menuItems); | 779 assertTrue(!!menuItems); |
| 805 MockInteractions.tap(menuItems[0]); // Action: Allow. | 780 MockInteractions.tap(menuItems[0]); // Action: Allow. |
| 806 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); | 781 return browserProxy.whenCalled('setCategoryPermissionForOrigin'); |
| 807 }).then(function(args) { | 782 }).then(function(args) { |
| 808 assertEquals('chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/', | 783 assertEquals('chrome-extension://cfhgfbfpcbnnbibfphagcjmgjfjmojfa/', |
| 809 args[0]); | 784 args[0]); |
| 810 assertEquals('', args[1]); | 785 assertEquals('', args[1]); |
| 811 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); | 786 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); |
| 812 assertEquals('allow', args[3]); | 787 assertEquals('allow', args[3]); |
| 813 }); | 788 }); |
| 814 }); | 789 }); |
| 815 }); | 790 }); |
| 816 } | 791 } |
| 817 return { | 792 return { |
| 818 registerTests: registerTests, | 793 registerTests: registerTests, |
| 819 }; | 794 }; |
| 820 }); | 795 }); |
| OLD | NEW |