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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 embeddingOrigin: 'bar-allow.com', | 80 embeddingOrigin: 'bar-allow.com', |
81 origin: 'bar-allow.com', | 81 origin: 'bar-allow.com', |
82 setting: 'allow', | 82 setting: 'allow', |
83 source: 'preference', | 83 source: 'preference', |
84 }, | 84 }, |
85 ] | 85 ] |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 /** | 89 /** |
90 * An example pref with mixed origin and pattern. | |
91 * @type {SiteSettingsPref} | |
92 */ | |
93 var prefsMixedOriginAndPattern = { | |
94 exceptions: { | |
95 media_stream_camera: [], | |
96 cookies: [], | |
97 fullscreen: [], | |
98 geolocation: [ | |
99 { | |
100 origin: 'https://foo.com', | |
101 embeddingOrigin: '*', | |
102 setting: 'allow', | |
103 source: 'preference', | |
104 }, | |
105 ], | |
106 javascript: [ | |
107 { | |
108 origin: 'https://[*.]foo.com', | |
109 embeddingOrigin: '*', | |
110 setting: 'allow', | |
111 source: 'preference', | |
112 }, | |
113 ], | |
114 images: [], | |
115 media_stream_mic: [], | |
116 notifications: [], | |
117 popups: [], | |
118 } | |
119 }; | |
120 | |
121 /** | |
90 * An example pref with multiple categories and multiple allow/block | 122 * An example pref with multiple categories and multiple allow/block |
91 * state. | 123 * state. |
92 * @type {SiteSettingsPref} | 124 * @type {SiteSettingsPref} |
93 */ | 125 */ |
94 var prefsVarious = { | 126 var prefsVarious = { |
95 exceptions: { | 127 exceptions: { |
96 media_stream_camera: [], | 128 media_stream_camera: [], |
97 cookies: [], | 129 cookies: [], |
98 fullscreen: [], | 130 fullscreen: [], |
99 geolocation: [ | 131 geolocation: [ |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 assertNotEquals(undefined, clickable); | 518 assertNotEquals(undefined, clickable); |
487 MockInteractions.tap(clickable); | 519 MockInteractions.tap(clickable); |
488 assertEquals(prefsVarious.exceptions.geolocation[0].origin, | 520 assertEquals(prefsVarious.exceptions.geolocation[0].origin, |
489 testElement.selectedSite.origin); | 521 testElement.selectedSite.origin); |
490 | 522 |
491 done(); | 523 done(); |
492 }); | 524 }); |
493 }); | 525 }); |
494 }); | 526 }); |
495 | 527 |
528 test('All sites mixed pattern and origin', function(done) { | |
529 // Prefs: One site, represented as origin and pattern. | |
530 setupAllSitesCategory(prefsMixedOriginAndPattern); | |
531 | |
532 browserProxy.whenCalled('getExceptionList').then( | |
533 function(contentType) { | |
534 testElement.async(function() { | |
535 // All Sites calls getExceptionList for all categories, starting | |
536 // with Cookies. | |
537 assertEquals(settings.ContentSettingsTypes.COOKIES, contentType); | |
538 | |
539 // Required for firstItem to be found below. | |
540 Polymer.dom.flush(); | |
541 | |
542 assertTrue(testElement.$.category.opened); | |
543 assertFalse(testElement.$.category.hidden); | |
544 // Validate that the sites gets populated from pre-canned prefs. | |
545 // If this fails with 2 instead of the expected 1, then the | |
michaelpg
2016/04/11 03:55:35
nit: move comment to assert message :-)
Finnur
2016/04/11 11:45:33
It doesn't really do anything because all asserts
michaelpg
2016/04/11 14:09:55
This is because the error is being thrown asynchro
| |
546 // de-duping of sites is not working for site_list. | |
547 assertEquals(1, testElement.sites.length); | |
548 assertEquals( | |
549 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, | |
550 testElement.sites[0].originForDisplay); | |
551 | |
552 assertEquals(undefined, testElement.selectedOrigin); | |
553 // Validate that the sites are shown in UI and can be selected. | |
554 var firstItem = testElement.$.listContainer.items[0]; | |
555 var clickable = firstItem.querySelector('.flex paper-item-body'); | |
556 assertNotEquals(undefined, clickable); | |
557 MockInteractions.tap(clickable); | |
558 assertEquals( | |
559 prefsMixedOriginAndPattern.exceptions.geolocation[0].origin, | |
560 testElement.selectedSite.originForDisplay); | |
561 | |
562 done(); | |
563 }); | |
564 }); | |
565 }); | |
566 | |
567 | |
496 test('Mixed schemes (present and absent)', function() { | 568 test('Mixed schemes (present and absent)', function() { |
497 // Prefs: One item with scheme and one without. | 569 // Prefs: One item with scheme and one without. |
498 setupLocationCategory(settings.PermissionValues.ALLOW, | 570 setupLocationCategory(settings.PermissionValues.ALLOW, |
499 prefsMixedSchemes); | 571 prefsMixedSchemes); |
500 return browserProxy.whenCalled('getExceptionList').then( | 572 return browserProxy.whenCalled('getExceptionList').then( |
501 function(contentType) { | 573 function(contentType) { |
502 // No further checks needed. If this fails, it will hang the test. | 574 // No further checks needed. If this fails, it will hang the test. |
503 }); | 575 }); |
504 }); | 576 }); |
505 }); | 577 }); |
506 } | 578 } |
507 return { | 579 return { |
508 registerTests: registerTests, | 580 registerTests: registerTests, |
509 }; | 581 }; |
510 }); | 582 }); |
OLD | NEW |