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

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

Issue 2426683003: [MD settings] remove count of content items in content settings (Closed)
Patch Set: removed exception counter tests Created 4 years, 2 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
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_settings_category.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 settings.PermissionValues.ALLOW, prefsEmpty); 394 settings.PermissionValues.ALLOW, prefsEmpty);
395 return browserProxy.whenCalled('getExceptionList').then( 395 return browserProxy.whenCalled('getExceptionList').then(
396 function(contentType) { 396 function(contentType) {
397 assertEquals( 397 assertEquals(
398 settings.ContentSettingsTypes.GEOLOCATION, contentType); 398 settings.ContentSettingsTypes.GEOLOCATION, contentType);
399 399
400 assertEquals(0, testElement.sites.length); 400 assertEquals(0, testElement.sites.length);
401 401
402 assertEquals( 402 assertEquals(
403 settings.PermissionValues.ALLOW, testElement.categorySubtype); 403 settings.PermissionValues.ALLOW, testElement.categorySubtype);
404 assertEquals('Allow - 0', testElement.$.header.innerText.trim());
dschuyler 2016/10/18 19:10:58 I considered shortening these to just test that i
Dan Beam 2016/10/18 19:24:15 nah, just remove, IMO
405 404
406 assertFalse(testElement.$.category.hidden); 405 assertFalse(testElement.$.category.hidden);
407 browserProxy.resetResolver('getExceptionList'); 406 browserProxy.resetResolver('getExceptionList');
408 testElement.categoryEnabled = false; 407 testElement.categoryEnabled = false;
409 return browserProxy.whenCalled('getExceptionList'); 408 return browserProxy.whenCalled('getExceptionList');
410 }).then(function(contentType) { 409 }).then(function(contentType) {
411 assertFalse(testElement.$.category.hidden); 410 assertFalse(testElement.$.category.hidden);
412 assertEquals('Exceptions - 0',
413 testElement.$.header.innerText.trim());
414 }); 411 });
415 }); 412 });
416 413
417 test('initial ALLOW state is correct', function() { 414 test('initial ALLOW state is correct', function() {
418 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 415 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
419 settings.PermissionValues.ALLOW, prefs); 416 settings.PermissionValues.ALLOW, prefs);
420 return browserProxy.whenCalled('getExceptionList').then( 417 return browserProxy.whenCalled('getExceptionList').then(
421 function(contentType) { 418 function(contentType) {
422 assertEquals( 419 assertEquals(
423 settings.ContentSettingsTypes.GEOLOCATION, contentType); 420 settings.ContentSettingsTypes.GEOLOCATION, contentType);
424 421
425 assertEquals(2, testElement.sites.length); 422 assertEquals(2, testElement.sites.length);
426 assertEquals(prefs.exceptions.geolocation[1].origin, 423 assertEquals(prefs.exceptions.geolocation[1].origin,
427 testElement.sites[0].origin); 424 testElement.sites[0].origin);
428 assertEquals( 425 assertEquals(
429 settings.PermissionValues.ALLOW, testElement.categorySubtype); 426 settings.PermissionValues.ALLOW, testElement.categorySubtype);
430 Polymer.dom.flush(); // Populates action menu. 427 Polymer.dom.flush(); // Populates action menu.
431 openActionMenu(0); 428 openActionMenu(0);
432 assertMenu(['Block', 'Remove'], testElement); 429 assertMenu(['Block', 'Remove'], testElement);
433 assertEquals('Allow - 2', testElement.$.header.innerText.trim());
434 430
435 // Site list should show, no matter what category default is set 431 // Site list should show, no matter what category default is set
436 // to. 432 // to.
437 assertFalse(testElement.$.category.hidden); 433 assertFalse(testElement.$.category.hidden);
438 browserProxy.resetResolver('getExceptionList'); 434 browserProxy.resetResolver('getExceptionList');
439 testElement.categoryEnabled = false; 435 testElement.categoryEnabled = false;
440 return browserProxy.whenCalled('getExceptionList'); 436 return browserProxy.whenCalled('getExceptionList');
441 }).then(function(contentType) { 437 }).then(function(contentType) {
442 assertFalse(testElement.$.category.hidden); 438 assertFalse(testElement.$.category.hidden);
443 assertEquals('Exceptions - 2',
444 testElement.$.header.innerText.trim());
445 }); 439 });
446 }); 440 });
447 441
448 test('initial BLOCK state is correct', function() { 442 test('initial BLOCK state is correct', function() {
449 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 443 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
450 settings.PermissionValues.BLOCK, prefs); 444 settings.PermissionValues.BLOCK, prefs);
451 return browserProxy.whenCalled('getExceptionList').then( 445 return browserProxy.whenCalled('getExceptionList').then(
452 function(contentType) { 446 function(contentType) {
453 assertEquals( 447 assertEquals(
454 settings.ContentSettingsTypes.GEOLOCATION, contentType); 448 settings.ContentSettingsTypes.GEOLOCATION, contentType);
455 449
456 assertEquals(2, testElement.sites.length); 450 assertEquals(2, testElement.sites.length);
457 assertEquals(prefs.exceptions.geolocation[3].origin, 451 assertEquals(prefs.exceptions.geolocation[3].origin,
458 testElement.sites[0].origin); 452 testElement.sites[0].origin);
459 453
460 assertEquals( 454 assertEquals(
461 settings.PermissionValues.BLOCK, testElement.categorySubtype); 455 settings.PermissionValues.BLOCK, testElement.categorySubtype);
462 Polymer.dom.flush(); // Populates action menu. 456 Polymer.dom.flush(); // Populates action menu.
463 openActionMenu(0); 457 openActionMenu(0);
464 assertMenu(['Allow', 'Remove'], testElement); 458 assertMenu(['Allow', 'Remove'], testElement);
465 assertEquals('Block - 2', testElement.$.header.innerText.trim());
466 459
467 // Site list should only show when category default is enabled. 460 // Site list should only show when category default is enabled.
468 assertFalse(testElement.$.category.hidden); 461 assertFalse(testElement.$.category.hidden);
469 browserProxy.resetResolver('getExceptionList'); 462 browserProxy.resetResolver('getExceptionList');
470 testElement.categoryEnabled = false; 463 testElement.categoryEnabled = false;
471 return browserProxy.whenCalled('getExceptionList'); 464 return browserProxy.whenCalled('getExceptionList');
472 }).then(function(contentType) { 465 }).then(function(contentType) {
473 assertTrue(testElement.$.category.hidden); 466 assertTrue(testElement.$.category.hidden);
474 }); 467 });
475 }); 468 });
476 469
477 test('initial SESSION ONLY state is correct', function() { 470 test('initial SESSION ONLY state is correct', function() {
478 setupCategory(settings.ContentSettingsTypes.COOKIES, 471 setupCategory(settings.ContentSettingsTypes.COOKIES,
479 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly); 472 settings.PermissionValues.SESSION_ONLY, prefsSessionOnly);
480 return browserProxy.whenCalled('getExceptionList').then( 473 return browserProxy.whenCalled('getExceptionList').then(
481 function(contentType) { 474 function(contentType) {
482 assertEquals( 475 assertEquals(
483 settings.ContentSettingsTypes.COOKIES, contentType); 476 settings.ContentSettingsTypes.COOKIES, contentType);
484 477
485 assertEquals(1, testElement.sites.length); 478 assertEquals(1, testElement.sites.length);
486 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin, 479 assertEquals(prefsSessionOnly.exceptions.cookies[2].origin,
487 testElement.sites[0].origin); 480 testElement.sites[0].origin);
488 481
489 assertEquals(settings.PermissionValues.SESSION_ONLY, 482 assertEquals(settings.PermissionValues.SESSION_ONLY,
490 testElement.categorySubtype); 483 testElement.categorySubtype);
491 Polymer.dom.flush(); // Populates action menu. 484 Polymer.dom.flush(); // Populates action menu.
492 openActionMenu(0); 485 openActionMenu(0);
493 assertMenu(['Allow', 'Block', 'Remove'], testElement); 486 assertMenu(['Allow', 'Block', 'Remove'], testElement);
494 assertEquals('Clear on exit - 1',
495 testElement.$.header.innerText.trim());
496 487
497 // Site list should show, no matter what category default is set 488 // Site list should show, no matter what category default is set
498 // to. 489 // to.
499 assertFalse(testElement.$.category.hidden); 490 assertFalse(testElement.$.category.hidden);
500 browserProxy.resetResolver('getExceptionList'); 491 browserProxy.resetResolver('getExceptionList');
501 testElement.categoryEnabled = false; 492 testElement.categoryEnabled = false;
502 return browserProxy.whenCalled('getExceptionList'); 493 return browserProxy.whenCalled('getExceptionList');
503 }).then(function(contentType) { 494 }).then(function(contentType) {
504 assertFalse(testElement.$.category.hidden); 495 assertFalse(testElement.$.category.hidden);
505 assertEquals('Clear on exit - 1', testElement.$.header.innerText);
506 }); 496 });
507 }); 497 });
508 498
509 test('initial INCOGNITO BLOCK state is correct', function() { 499 test('initial INCOGNITO BLOCK state is correct', function() {
510 setupCategory(settings.ContentSettingsTypes.COOKIES, 500 setupCategory(settings.ContentSettingsTypes.COOKIES,
511 settings.PermissionValues.BLOCK, prefsIncognito); 501 settings.PermissionValues.BLOCK, prefsIncognito);
512 return browserProxy.whenCalled('getExceptionList').then( 502 return browserProxy.whenCalled('getExceptionList').then(
513 function(contentType) { 503 function(contentType) {
514 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType); 504 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType);
515 505
516 assertEquals(1, testElement.sites.length); 506 assertEquals(1, testElement.sites.length);
517 assertEquals(prefsIncognito.exceptions.cookies[0].origin, 507 assertEquals(prefsIncognito.exceptions.cookies[0].origin,
518 testElement.sites[0].origin); 508 testElement.sites[0].origin);
519 509
520 assertEquals(settings.PermissionValues.BLOCK, 510 assertEquals(settings.PermissionValues.BLOCK,
521 testElement.categorySubtype); 511 testElement.categorySubtype);
522 Polymer.dom.flush(); // Populates action menu. 512 Polymer.dom.flush(); // Populates action menu.
523 openActionMenu(0); 513 openActionMenu(0);
524 // 'Clear on exit' is visible as this is not an incognito item. 514 // 'Clear on exit' is visible as this is not an incognito item.
525 assertMenu(['Allow', 'Clear on exit', 'Remove'], testElement); 515 assertMenu(['Allow', 'Clear on exit', 'Remove'], testElement);
526 assertEquals('Block - 1',
527 testElement.$.header.innerText.trim());
528 516
529 // Select 'Remove from menu'. 517 // Select 'Remove from menu'.
530 var menuItems = getMenuItems(testElement.$.listContainer, 0); 518 var menuItems = getMenuItems(testElement.$.listContainer, 0);
531 assertTrue(!!menuItems); 519 assertTrue(!!menuItems);
532 MockInteractions.tap(menuItems[2]); 520 MockInteractions.tap(menuItems[2]);
533 return browserProxy.whenCalled( 521 return browserProxy.whenCalled(
534 'resetCategoryPermissionForOrigin'); 522 'resetCategoryPermissionForOrigin');
535 }).then(function(args) { 523 }).then(function(args) {
536 assertEquals('http://foo.com', args[0]); 524 assertEquals('http://foo.com', args[0]);
537 assertEquals('http://foo.com', args[1]); 525 assertEquals('http://foo.com', args[1]);
(...skipping 15 matching lines...) Expand all
553 testElement.sites[0].origin); 541 testElement.sites[0].origin);
554 assertEquals(prefsIncognito.exceptions.cookies[1].origin, 542 assertEquals(prefsIncognito.exceptions.cookies[1].origin,
555 testElement.sites[1].origin); 543 testElement.sites[1].origin);
556 544
557 assertEquals(settings.PermissionValues.ALLOW, 545 assertEquals(settings.PermissionValues.ALLOW,
558 testElement.categorySubtype); 546 testElement.categorySubtype);
559 Polymer.dom.flush(); // Populates action menu. 547 Polymer.dom.flush(); // Populates action menu.
560 openActionMenu(0); 548 openActionMenu(0);
561 // 'Clear on exit' is hidden for incognito items. 549 // 'Clear on exit' is hidden for incognito items.
562 assertMenu(['Block', 'Remove'], testElement); 550 assertMenu(['Block', 'Remove'], testElement);
563 assertEquals('Allow - 2',
564 testElement.$.header.innerText.trim());
565 551
566 // Select 'Remove' from menu on 'foo.com'. 552 // Select 'Remove' from menu on 'foo.com'.
567 openActionMenu(1); 553 openActionMenu(1);
568 var menuItems = getMenuItems(testElement.$.listContainer, 1); 554 var menuItems = getMenuItems(testElement.$.listContainer, 1);
569 assertTrue(!!menuItems); 555 assertTrue(!!menuItems);
570 MockInteractions.tap(menuItems[1]); 556 MockInteractions.tap(menuItems[1]);
571 return browserProxy.whenCalled( 557 return browserProxy.whenCalled(
572 'resetCategoryPermissionForOrigin'); 558 'resetCategoryPermissionForOrigin');
573 }).then(function(args) { 559 }).then(function(args) {
574 assertEquals('http://foo.com', args[0]); 560 assertEquals('http://foo.com', args[0]);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]); 814 assertEquals(settings.ContentSettingsTypes.JAVASCRIPT, args[2]);
829 assertEquals('allow', args[3]); 815 assertEquals('allow', args[3]);
830 }); 816 });
831 }); 817 });
832 }); 818 });
833 } 819 }
834 return { 820 return {
835 registerTests: registerTests, 821 registerTests: registerTests,
836 }; 822 };
837 }); 823 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_settings_category.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698