| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** @fileoverview Suite of tests for site-data-details-subpage. */ |
| 6 suite('SiteDataDetailsSubpage', function() { |
| 7 /** @type {?SiteDataDetailsSubpageElement} */ |
| 8 var page = null; |
| 9 |
| 10 /** @type {TestSiteSettingsPrefsBrowserProxy} */ |
| 11 var browserProxy = null; |
| 12 /** @type {!CookieDetails} */ |
| 13 var cookieDetails = { |
| 14 accessibleToScript: "Yes", |
| 15 content: "dummy_cookie_contents", |
| 16 created: "Tuesday, February 7, 2017 at 11:28:45 AM", |
| 17 domain: ".foo.com", |
| 18 expires: "Wednesday, February 7, 2018 at 11:28:45 AM", |
| 19 hasChildren: false, |
| 20 id: "328", |
| 21 idPath: "74,165,328", |
| 22 name: "abcd", |
| 23 path: "/", |
| 24 sendfor: "Any kind of connection", |
| 25 title: "abcd", |
| 26 type: "cookie" |
| 27 }; |
| 28 |
| 29 /** @type {!CookieList} */ |
| 30 var cookieList = { |
| 31 id: 'fooId', |
| 32 children: [cookieDetails], |
| 33 }; |
| 34 |
| 35 var site = 'foo.com'; |
| 36 |
| 37 setup(function() { |
| 38 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); |
| 39 browserProxy.setCookieDetails(cookieList); |
| 40 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; |
| 41 PolymerTest.clearBody(); |
| 42 page = document.createElement('site-data-details-subpage'); |
| 43 settings.navigateTo( |
| 44 settings.Route.SITE_SETTINGS_DATA_DETAILS, |
| 45 new URLSearchParams('site=' + site)); |
| 46 |
| 47 document.body.appendChild(page); |
| 48 }); |
| 49 |
| 50 teardown(function() { |
| 51 settings.navigateTo(settings.Route.BASIC); |
| 52 }); |
| 53 |
| 54 test('DetailsShownForCookie', function() { |
| 55 return browserProxy.whenCalled('getCookieDetails').then( |
| 56 function(actualSite) { |
| 57 assertEquals(site, actualSite); |
| 58 |
| 59 Polymer.dom.flush(); |
| 60 var entries = page.root.querySelectorAll('.settings-box'); |
| 61 assertEquals(1, entries.length); |
| 62 |
| 63 var listItems = page.root.querySelectorAll('.list-item'); |
| 64 // |cookieInfo| is a global var defined in |
| 65 // site_settings/cookie_info.js, and specifies the fields that are |
| 66 // shown for a cookie. |
| 67 assertEquals(cookieInfo.cookie.length, listItems.length); |
| 68 |
| 69 // Check that all the cookie information is presented in the DOM. |
| 70 var cookieDetailValues = page.root.querySelectorAll('.secondary'); |
| 71 cookieDetailValues.forEach(function(div, i) { |
| 72 var key = cookieInfo.cookie[i][0]; |
| 73 assertEquals(cookieDetails[key], div.textContent); |
| 74 }); |
| 75 }); |
| 76 }); |
| 77 }); |
| OLD | NEW |