Chromium Code Reviews| Index: chrome/test/data/webui/settings/site_data_details_subpage_tests.js |
| diff --git a/chrome/test/data/webui/settings/site_data_details_subpage_tests.js b/chrome/test/data/webui/settings/site_data_details_subpage_tests.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..41a503f498f70deb419ad5414694a9f66fd1a04b |
| --- /dev/null |
| +++ b/chrome/test/data/webui/settings/site_data_details_subpage_tests.js |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('site_data_details', function() { |
| + function registerTests() { |
| + /** @fileoverview Suite of tests for site-data-details-subpage. */ |
| + suite('SiteDataDetailsSubpage', function() { |
| + /** @type {?SiteDataDetailsSubpageElement} */ |
| + var page = null; |
| + |
| + /** @type {TestSiteSettingsPrefsBrowserProxy} */ |
| + var browserProxy = null; |
| + /** @type {!CookieDetails} */ |
| + var cookieDetails = { |
| + accessibleToScript: "Yes", |
| + content: "dummy_cookie_contents", |
| + created: "Tuesday, February 7, 2017 at 11:28:45 AM", |
| + domain: ".foo.com", |
| + expires: "Wednesday, February 7, 2018 at 11:28:45 AM", |
| + hasChildren: false, |
| + id: "328", |
| + idPath: "74,165,328", |
| + name: "abcd", |
| + path: "/", |
| + sendfor: "Any kind of connection", |
| + title: "abcd", |
| + type: "cookie" |
| + }; |
| + |
| + /** @type {!CookieList} */ |
| + var cookieList = { |
| + id: 'fooId', |
| + children: [cookieDetails], |
| + }; |
| + |
| + var site = 'foo.com'; |
| + |
| + setup(function() { |
| + browserProxy = new TestSiteSettingsPrefsBrowserProxy(); |
| + browserProxy.setCookieDetails(cookieList); |
| + settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; |
| + PolymerTest.clearBody(); |
| + page = document.createElement('site-data-details-subpage'); |
| + settings.navigateTo( |
| + settings.Route.SITE_SETTINGS_DATA_DETAILS, |
| + new URLSearchParams('site=' + site)); |
| + |
| + document.body.appendChild(page); |
| + }); |
| + |
| + test('DetailsShownForCookie', function() { |
| + return browserProxy.whenCalled('getCookieDetails').then( |
|
tommycli
2017/02/08 19:28:40
This test does fail without the one char change ri
dpapad
2017/02/08 22:01:09
Yes, I doubled checked that. It fails with the fol
|
| + function(actualSite) { |
| + assertEquals(site, actualSite); |
| + |
| + Polymer.dom.flush(); |
| + var entries = page.root.querySelectorAll('.settings-box'); |
| + assertEquals(1, entries.length); |
| + |
| + var listItems = page.root.querySelectorAll('.list-item'); |
| + // |cookieInfo| is a global var defined in |
| + // site_settings/cookie_info.js, and specifies the fields that are |
| + // shown for a cookie. |
| + assertEquals(cookieInfo.cookie.length, listItems.length); |
| + |
| + // Check that all the cookie information is presented in the DOM. |
| + var cookieDetailValues = page.root.querySelectorAll('.secondary'); |
| + cookieDetailValues.forEach(function(div, i) { |
| + var key = cookieInfo.cookie[i][0]; |
| + assertEquals(cookieDetails[key], div.textContent); |
| + }); |
| + }); |
| + }); |
| + }); |
| + } |
| + |
| + return { |
| + registerTests: registerTests, |
| + }; |
| +}); |