Commit 5cc13460 authored by sauski's avatar sauski Committed by Commit Bot

WebUI Settings: Add type checking to privacy_page_test.js

Added JS type checking for:
    - privacy_page_test.js
    - clear_browsing_data_browser_proxy.js

Bug: 1000989
Change-Id: I98d2a388a150af153c50118a994fa3c9e83ac37b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377722Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Theodore Olsauskas-Warren <sauski@google.com>
Cr-Commit-Position: refs/heads/master@{#803408}
parent 495636c7
......@@ -261,6 +261,7 @@ js_library("lazy_load") {
"autofill_page:autofill_section",
"autofill_page:payments_section",
"chrome_cleanup_page:chrome_cleanup_proxy",
"clear_browsing_data_dialog:clear_browsing_data_browser_proxy",
"languages_page:languages_browser_proxy.m",
"languages_page:languages_metrics_proxy",
"languages_page:languages_page",
......
......@@ -20,6 +20,7 @@ js_library("basic_page") {
"..:search_settings.m",
"../chrome_cleanup_page:chrome_cleanup_proxy",
"../prefs:prefs_behavior.m",
"../privacy_page:privacy_page",
"../safety_check_page:safety_check_page",
"../search_page",
"../settings_page:main_page_behavior",
......
......@@ -63,7 +63,7 @@ export {ChromeCleanupIdleReason} from './chrome_cleanup_page/chrome_cleanup_page
export {ChromeCleanupProxy, ChromeCleanupProxyImpl} from './chrome_cleanup_page/chrome_cleanup_proxy.js';
export {CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW} from './chrome_cleanup_page/items_to_remove_list.js';
// </if>
export {ClearBrowsingDataBrowserProxyImpl} from './clear_browsing_data_dialog/clear_browsing_data_browser_proxy.js';
export {ClearBrowsingDataBrowserProxy, ClearBrowsingDataBrowserProxyImpl, InstalledApp} from './clear_browsing_data_dialog/clear_browsing_data_browser_proxy.js';
export {DownloadsBrowserProxyImpl} from './downloads_page/downloads_browser_proxy.js';
// <if expr="_google_chrome and is_win">
export {IncompatibleApplication, IncompatibleApplicationsBrowserProxyImpl} from './incompatible_applications_page/incompatible_applications_browser_proxy.js';
......
......@@ -129,7 +129,8 @@ js_type_check("closure_compile") {
#":pref_util_tests",
#":prefs_test_cases",
#":prefs_tests",
#":privacy_page_test",
":privacy_page_test",
#":protocol_handlers_tests",
#":recent_site_permissions_test",
#":reset_page_test",
......@@ -178,7 +179,8 @@ js_type_check("closure_compile") {
":test_about_page_browser_proxy",
#":test_android_info_browser_proxy",
#":test_clear_browsing_data_browser_proxy",
":test_clear_browsing_data_browser_proxy",
#":test_extension_control_browser_proxy",
":test_hats_browser_proxy",
":test_languages_browser_proxy.m",
......@@ -289,6 +291,23 @@ js_library("passwords_and_autofill_fake_data") {
"$externs_path/passwords_private.js",
]
}
js_library("privacy_page_test") {
deps = [
":test_clear_browsing_data_browser_proxy",
":test_hats_browser_proxy",
":test_metrics_browser_proxy",
":test_privacy_page_browser_proxy",
":test_site_settings_prefs_browser_proxy",
":test_sync_browser_proxy.m",
"..:chai_assert",
"..:test_util.m",
"//chrome/browser/resources/settings:lazy_load",
"//chrome/browser/resources/settings:settings",
"//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:load_time_data.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
}
js_library("safety_check_chrome_cleaner_test") {
deps = [
......@@ -418,6 +437,14 @@ js_library("test_about_page_browser_proxy") {
extra_deps = [ ":modulize_local" ]
}
js_library("test_clear_browsing_data_browser_proxy") {
deps = [
"..:test_browser_proxy.m",
"//chrome/browser/resources/settings:lazy_load",
"//ui/webui/resources/js:cr.m",
]
}
js_library("test_hats_browser_proxy") {
deps = [
"..:test_browser_proxy.m",
......
......@@ -3,38 +3,38 @@
// found in the LICENSE file.
// clang-format off
import {isMac, isWindows, webUIListenerCallback} from 'chrome://resources/js/cr.m.js';
import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {ClearBrowsingDataBrowserProxyImpl, CookieControlsMode, SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js';
import {SafeBrowsingSetting} from 'chrome://settings/lazy_load.js';
import {ClearBrowsingDataBrowserProxyImpl, CookieControlsMode, SafeBrowsingSetting, SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js';
import {HatsBrowserProxyImpl, MetricsBrowserProxyImpl, PrivacyElementInteractions, PrivacyPageBrowserProxyImpl, Router, routes, SecureDnsMode, SyncBrowserProxyImpl} from 'chrome://settings/settings.js';
import {TestClearBrowsingDataBrowserProxy} from 'chrome://test/settings/test_clear_browsing_data_browser_proxy.js';
import {TestHatsBrowserProxy} from 'chrome://test/settings/test_hats_browser_proxy.js';
import {TestMetricsBrowserProxy} from 'chrome://test/settings/test_metrics_browser_proxy.js';
import {TestPrivacyPageBrowserProxy} from 'chrome://test/settings/test_privacy_page_browser_proxy.js';
import {TestSiteSettingsPrefsBrowserProxy} from 'chrome://test/settings/test_site_settings_prefs_browser_proxy.js';
import {TestSyncBrowserProxy} from 'chrome://test/settings/test_sync_browser_proxy.m.js';
import {flushTasks, isChildVisible, whenAttributeIs} from 'chrome://test/test_util.m.js';
import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
import {flushTasks} from '../test_util.m.js';
import {TestClearBrowsingDataBrowserProxy} from './test_clear_browsing_data_browser_proxy.js';
import {TestHatsBrowserProxy} from './test_hats_browser_proxy.js';
import {TestMetricsBrowserProxy} from './test_metrics_browser_proxy.js';
import {TestPrivacyPageBrowserProxy} from './test_privacy_page_browser_proxy.js';
import {TestSiteSettingsPrefsBrowserProxy} from './test_site_settings_prefs_browser_proxy.js';
import {TestSyncBrowserProxy} from './test_sync_browser_proxy.m.js';
// clang-format on
suite('PrivacyPage', function() {
/** @type {SettingsPrivacyPageElement} */
/** @type {!SettingsPrivacyPageElement} */
let page;
/** @type {TestClearBrowsingDataBrowserProxy} */
/** @type {!TestClearBrowsingDataBrowserProxy} */
let testClearBrowsingDataBrowserProxy;
/** @type {TestSiteSettingsPrefsBrowserProxy}*/
let siteSettingsBrowserProxy = null;
/** @type {!TestSiteSettingsPrefsBrowserProxy}*/
let siteSettingsBrowserProxy;
/** @type {Array<string>} */
/** @type {!Array<string>} */
const testLabels = ['test label 1', 'test label 2'];
setup(async function() {
PolymerTest.clearBody();
testClearBrowsingDataBrowserProxy = new TestClearBrowsingDataBrowserProxy();
ClearBrowsingDataBrowserProxyImpl.instance_ =
testClearBrowsingDataBrowserProxy;
......@@ -46,7 +46,9 @@ suite('PrivacyPage', function() {
SiteSettingsPrefsBrowserProxyImpl.instance_ = siteSettingsBrowserProxy;
siteSettingsBrowserProxy.setCookieSettingDescription(testLabels[0]);
page = document.createElement('settings-privacy-page');
document.body.innerHTML = '';
page = /** @type {!SettingsPrivacyPageElement} */
(document.createElement('settings-privacy-page'));
page.prefs = {
profile: {password_manager_leak_detection: {value: true}},
signin: {
......@@ -87,14 +89,13 @@ suite('PrivacyPage', function() {
webUIListenerCallback('cookieSettingDescriptionChanged', testLabels[1]);
assertEquals(page.$$('#cookiesLinkRow').subLabel, testLabels[1]);
});
});
suite('PrivacyPageSound', function() {
/** @type {TestPrivacyPageBrowserProxy} */
/** @type {!TestPrivacyPageBrowserProxy} */
let testBrowserProxy;
/** @type {SettingsPrivacyPageElement} */
/** @type {!SettingsPrivacyPageElement} */
let page;
function flushAsync() {
......@@ -115,10 +116,11 @@ suite('PrivacyPageSound', function() {
testBrowserProxy = new TestPrivacyPageBrowserProxy();
PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy;
PolymerTest.clearBody();
Router.getInstance().navigateTo(routes.SITE_SETTINGS_SOUND);
page = document.createElement('settings-privacy-page');
document.body.innerHTML = '';
page = /** @type {!SettingsPrivacyPageElement} */
(document.createElement('settings-privacy-page'));
document.body.appendChild(page);
return flushAsync();
});
......@@ -170,7 +172,8 @@ suite('PrivacyPageSound', function() {
loadTimeData.overrideValues({enableBlockAutoplayContentSetting: false});
page.remove();
page = document.createElement('settings-privacy-page');
page = /** @type {!SettingsPrivacyPageElement} */
(document.createElement('settings-privacy-page'));
document.body.appendChild(page);
return flushAsync().then(() => {
......@@ -202,17 +205,18 @@ suite('PrivacyPageSound', function() {
});
suite('HappinessTrackingSurveys', function() {
/** @type {TestHatsBrowserProxy} */
/** @type {!TestHatsBrowserProxy} */
let testHatsBrowserProxy;
/** @type {SettingsPrivacyPageElement} */
/** @type {!SettingsPrivacyPageElement} */
let page;
setup(function() {
testHatsBrowserProxy = new TestHatsBrowserProxy();
HatsBrowserProxyImpl.instance_ = testHatsBrowserProxy;
PolymerTest.clearBody();
page = document.createElement('settings-privacy-page');
document.body.innerHTML = '';
page = /** @type {!SettingsPrivacyPageElement} */
(document.createElement('settings-privacy-page'));
// Initialize the privacy page pref. Security page manually expands
// the initially selected safe browsing option so the pref object
// needs to be defined.
......
......@@ -2,8 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js';
import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js';
import {ClearBrowsingDataBrowserProxy, InstalledApp, LanguagesBrowserProxy} from 'chrome://settings/lazy_load.js';
import {TestBrowserProxy} from '../test_browser_proxy.m.js';
// clang-format on
/** @implements {ClearBrowsingDataBrowserProxy} */
export class TestClearBrowsingDataBrowserProxy extends TestBrowserProxy {
......@@ -54,6 +59,6 @@ export class TestClearBrowsingDataBrowserProxy extends TestBrowserProxy {
/** @override */
initialize() {
this.methodCalled('initialize');
return Promise.resolve(false);
return Promise.resolve();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment