Commit 0e2346c3 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Settings: Autogenerate Polymer 3 controls

- Add js_modulizer and polymer_modulizer rules to autogenerate Polymer 3
  versions of most files in controls/ and their dependencies.
- Note: settings_idle_load is excluded, as it may not be feasible
  to autogenerate (may need to check in a manually created P3 version).
- Add closure compilation targets for the Polymer 3 files.
- Autogenerate P3 versions of browser_tests for the elements that have
  browser_tests currently.

Bug: 1026426
Change-Id: I55d77c0432fb81df5e6976987685477d2bbc0cc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024283
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736924}
parent f15a7195
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//chrome/common/features.gni") import("//chrome/common/features.gni")
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni") import("//tools/grit/grit_rule.gni")
import("//tools/polymer/polymer.gni")
import("//ui/webui/resources/tools/js_modulizer.gni") import("//ui/webui/resources/tools/js_modulizer.gni")
import("//ui/webui/webui_features.gni") import("//ui/webui/webui_features.gni")
import("../optimize_webui.gni") import("../optimize_webui.gni")
...@@ -90,6 +91,11 @@ group("closure_compile") { ...@@ -90,6 +91,11 @@ group("closure_compile") {
"settings_ui:closure_compile", "settings_ui:closure_compile",
"site_settings:closure_compile", "site_settings:closure_compile",
"site_settings_page:closure_compile", "site_settings_page:closure_compile",
# Polymer3 related targets
":settings_module_resources",
"controls:closure_compile_module",
"prefs:closure_compile_module",
] ]
if (is_win) { if (is_win) {
...@@ -194,9 +200,65 @@ js_library("search_settings") { ...@@ -194,9 +200,65 @@ js_library("search_settings") {
# Polymer 3 related rules. # Polymer 3 related rules.
group("polymer3_elements") { group("polymer3_elements") {
public_deps = [ ":modulize" ] public_deps = [
":polymer3_elements_local",
"controls:polymer3_elements",
"prefs:modulize",
]
}
group("polymer3_elements_local") {
public_deps = [
":modulize",
":settings_shared_css_module",
":settings_vars_css_module",
]
}
polymer_modulizer("settings_vars_css") {
js_file = "settings_vars_css.m.js"
html_file = "settings_vars_css.html"
html_type = "custom-style"
}
polymer_modulizer("settings_shared_css") {
js_file = "settings_shared_css.m.js"
html_file = "settings_shared_css.html"
html_type = "style-module"
} }
js_modulizer("modulize") { js_modulizer("modulize") {
input_files = [ "search_settings.js" ] input_files = [
"extension_control_browser_proxy.js",
"router.js",
"search_settings.js",
]
namespace_rewrites = [
"cr.addSingletonGetter|addSingletonGetter",
"settings.ExtensionControlBrowserProxy|ExtensionControlBrowserProxy",
"settings.Route|Route",
"settings.MinimumRoutes|MinimumRoutes",
]
}
js_type_check("settings_module_resources") {
is_polymer3 = true
deps = [
":extension_control_browser_proxy.m",
":router.m",
]
}
js_library("extension_control_browser_proxy.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/extension_control_browser_proxy.m.js" ]
deps = [ "//ui/webui/resources/js:cr.m" ]
extra_deps = [ ":modulize" ]
externs_list = [ "$externs_path/chrome_send.js" ]
}
js_library("router.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/router.m.js" ]
deps = [ "//ui/webui/resources/js:assert.m" ]
extra_deps = [ ":modulize" ]
externs_list = [ "$externs_path/metrics_private.js" ]
} }
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
* </settings-password-prompt-dialog> * </settings-password-prompt-dialog>
*/ */
(function() {
'use strict';
Polymer({ Polymer({
is: 'settings-password-prompt-dialog', is: 'settings-password-prompt-dialog',
...@@ -68,7 +65,7 @@ Polymer({ ...@@ -68,7 +65,7 @@ Polymer({
/** /**
* Interface for chrome.quickUnlockPrivate calls. May be overridden by * Interface for chrome.quickUnlockPrivate calls. May be overridden by
* tests. * tests.
* @type {QuickUnlockPrivate} * @type {Object}
*/ */
quickUnlockPrivate: {type: Object, value: chrome.quickUnlockPrivate}, quickUnlockPrivate: {type: Object, value: chrome.quickUnlockPrivate},
...@@ -81,7 +78,7 @@ Polymer({ ...@@ -81,7 +78,7 @@ Polymer({
/** @return {!CrInputElement} */ /** @return {!CrInputElement} */
get passwordInput() { get passwordInput() {
return this.$.passwordInput; return /** @type {!CrInputElement} */ (this.$.passwordInput);
}, },
/** @override */ /** @override */
...@@ -167,4 +164,3 @@ Polymer({ ...@@ -167,4 +164,3 @@ Polymer({
this.inputValue_; this.inputValue_;
}, },
}); });
})();
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {CrSettingsPrefs} from '../prefs/prefs_types.m.js';
/** /**
* @polymerBehavior Tracks the initialization of a specified preference and * @polymerBehavior Tracks the initialization of a specified preference and
* logs an error if the pref is not defined after prefs have been fetched. * logs an error if the pref is not defined after prefs have been fetched.
*/ */
const PrefControlBehavior = { /* #export */ const PrefControlBehavior = {
properties: { properties: {
/** /**
* The Preference object being tracked. * The Preference object being tracked.
...@@ -35,7 +37,7 @@ const PrefControlBehavior = { ...@@ -35,7 +37,7 @@ const PrefControlBehavior = {
if (this.id) { if (this.id) {
error += '#' + this.id; error += '#' + this.id;
} }
error += ' in ' + this.domHost.tagName; error += ' in ' + this.getRootNode().host.tagName;
console.error(error); console.error(error);
} else if ( } else if (
this.pref.enforcement == this.pref.enforcement ==
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {CrPolicyPrefBehavior} from 'chrome://resources/cr_elements/policy/cr_policy_pref_behavior.m.js';
// #import {PrefControlBehavior} from './pref_control_behavior.m.js';
// clang-format on
/** /**
* @fileoverview * @fileoverview
* A behavior to help controls that handle a boolean preference, such as * A behavior to help controls that handle a boolean preference, such as
...@@ -131,7 +137,7 @@ const SettingsBooleanControlBehaviorImpl = { ...@@ -131,7 +137,7 @@ const SettingsBooleanControlBehaviorImpl = {
}; };
/** @polymerBehavior */ /** @polymerBehavior */
const SettingsBooleanControlBehavior = [ /* #export */ const SettingsBooleanControlBehavior = [
CrPolicyPrefBehavior, CrPolicyPrefBehavior,
PrefControlBehavior, PrefControlBehavior,
SettingsBooleanControlBehaviorImpl, SettingsBooleanControlBehaviorImpl,
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
cr.define('settings', function() { cr.define('settings', function() {
/** @interface */ /** @interface */
class ExtensionControlBrowserProxy { /* #export */ class ExtensionControlBrowserProxy {
// TODO(dbeam): should be be returning !Promise<boolean> to indicate whether // TODO(dbeam): should be be returning !Promise<boolean> to indicate whether
// it succeeded? // it succeeded?
/** @param {string} extensionId */ /** @param {string} extensionId */
...@@ -17,7 +19,7 @@ cr.define('settings', function() { ...@@ -17,7 +19,7 @@ cr.define('settings', function() {
/** /**
* @implements {settings.ExtensionControlBrowserProxy} * @implements {settings.ExtensionControlBrowserProxy}
*/ */
class ExtensionControlBrowserProxyImpl { /* #export */ class ExtensionControlBrowserProxyImpl {
/** @override */ /** @override */
disableExtension(extensionId) { disableExtension(extensionId) {
chrome.send('disableExtension', [extensionId]); chrome.send('disableExtension', [extensionId]);
......
// Copyright 2019 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.
import './strings.m.js';
export {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
js_type_check("closure_compile") { js_type_check("closure_compile") {
deps = [ deps = [
...@@ -36,3 +37,33 @@ js_library("prefs_behavior") { ...@@ -36,3 +37,33 @@ js_library("prefs_behavior") {
js_library("prefs_types") { js_library("prefs_types") {
} }
js_modulizer("modulize") {
input_files = [
"pref_util.js",
"prefs_types.js",
]
}
js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [
":pref_util.m",
":prefs_types.m",
]
}
js_library("prefs_types.m") {
sources = [
"$root_gen_dir/chrome/browser/resources/settings/prefs/prefs_types.m.js",
]
extra_deps = [ ":modulize" ]
}
js_library("pref_util.m") {
sources =
[ "$root_gen_dir/chrome/browser/resources/settings/prefs/pref_util.m.js" ]
deps = [ "//ui/webui/resources/js:assert.m" ]
externs_list = [ "$externs_path/settings_private.js" ]
extra_deps = [ ":modulize" ]
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
/** @fileoverview Utility functions to help use prefs in Polymer controls. */ /** @fileoverview Utility functions to help use prefs in Polymer controls. */
// #import {assertNotReached} from 'chrome://resources/js/assert.m.js';
// TODO(michaelpg): converge with other WebUI on capitalization. This is // TODO(michaelpg): converge with other WebUI on capitalization. This is
// consistent with Settings, but WebUI uses lower.underscore_case. // consistent with Settings, but WebUI uses lower.underscore_case.
cr.define('Settings.PrefUtil', function() { cr.define('Settings.PrefUtil', function() {
...@@ -13,7 +15,7 @@ cr.define('Settings.PrefUtil', function() { ...@@ -13,7 +15,7 @@ cr.define('Settings.PrefUtil', function() {
* @param {!chrome.settingsPrivate.PrefObject} pref * @param {!chrome.settingsPrivate.PrefObject} pref
* @return {boolean|number|string|undefined} * @return {boolean|number|string|undefined}
*/ */
function stringToPrefValue(value, pref) { /* #export */ function stringToPrefValue(value, pref) {
switch (pref.type) { switch (pref.type) {
case chrome.settingsPrivate.PrefType.BOOLEAN: case chrome.settingsPrivate.PrefType.BOOLEAN:
return value == 'true'; return value == 'true';
...@@ -39,7 +41,7 @@ cr.define('Settings.PrefUtil', function() { ...@@ -39,7 +41,7 @@ cr.define('Settings.PrefUtil', function() {
* @param {!chrome.settingsPrivate.PrefObject} pref * @param {!chrome.settingsPrivate.PrefObject} pref
* @return {string} * @return {string}
*/ */
function prefToString(pref) { /* #export */ function prefToString(pref) {
switch (pref.type) { switch (pref.type) {
case chrome.settingsPrivate.PrefType.BOOLEAN: case chrome.settingsPrivate.PrefType.BOOLEAN:
case chrome.settingsPrivate.PrefType.NUMBER: case chrome.settingsPrivate.PrefType.NUMBER:
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/** /**
* Global state for prefs status. * Global state for prefs status.
*/ */
const CrSettingsPrefs = (function() { /* #export */ const CrSettingsPrefs = (function() {
const CrSettingsPrefsInternal = { const CrSettingsPrefsInternal = {
/** /**
* Resolves the CrSettingsPrefs.initialized promise. * Resolves the CrSettingsPrefs.initialized promise.
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {assert, assertNotReached} from 'chrome://resources/js/assert.m.js';
cr.define('settings', function() { cr.define('settings', function() {
/** /**
* @typedef {{ * @typedef {{
...@@ -9,10 +11,10 @@ cr.define('settings', function() { ...@@ -9,10 +11,10 @@ cr.define('settings', function() {
* ADVANCED: (settings.Route|undefined), * ADVANCED: (settings.Route|undefined),
* }} * }}
*/ */
let MinimumRoutes; /* #export */ let MinimumRoutes;
/** Class for navigable routes. */ /** Class for navigable routes. */
class Route { /* #export */ class Route {
/** @param {string} path */ /** @param {string} path */
constructor(path) { constructor(path) {
/** @type {string} */ /** @type {string} */
...@@ -114,7 +116,7 @@ cr.define('settings', function() { ...@@ -114,7 +116,7 @@ cr.define('settings', function() {
/** @type {?settings.Router} */ /** @type {?settings.Router} */
let routerInstance = null; let routerInstance = null;
class Router { /* #export */ class Router {
/** @return {!settings.Router} The singleton instance. */ /** @return {!settings.Router} The singleton instance. */
static getInstance() { static getInstance() {
return assert(routerInstance); return assert(routerInstance);
...@@ -340,7 +342,7 @@ cr.define('settings', function() { ...@@ -340,7 +342,7 @@ cr.define('settings', function() {
} }
/** @polymerBehavior */ /** @polymerBehavior */
const RouteObserverBehavior = { /* #export */ const RouteObserverBehavior = {
/** @override */ /** @override */
attached() { attached() {
routerInstance.addObserver(this); routerInstance.addObserver(this);
......
import {getSearchManager} from 'chrome://settings/search_settings.m.js'; // Copyright 2020 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.
console.log('getSearchManager', getSearchManager); import 'chrome://settings/controls/controlled_button.m.js';
import 'chrome://settings/controls/controlled_radio_button.m.js';
import 'chrome://settings/controls/extension_controlled_indicator.m.js';
import 'chrome://settings/controls/settings_checkbox.m.js';
import 'chrome://settings/controls/settings_dropdown_menu.m.js';
import 'chrome://settings/controls/settings_slider.m.js';
import 'chrome://settings/controls/settings_textarea.m.js';
import 'chrome://settings/controls/settings_toggle_button.m.js';
export {ExtensionControlBrowserProxyImpl} from 'chrome://settings/extension_control_browser_proxy.m.js';
export {prefToString, stringToPrefValue} from 'chrome://settings/prefs/pref_util.m.js';
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<grit-part> <grit-part>
<!-- Polymer 3.0 Elements -->
<include name="IDR_SETTINGS_CONTROLS_CONTROLLED_BUTTON_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/controlled_button.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_CONTROLLED_RADIO_BUTTON_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/controlled_radio_button.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_EXTENSION_CONTROLLED_INDICATOR_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/extension_controlled_indicator.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_PASSWORD_PROMPT_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/password_prompt_dialog.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_BOOLEAN_CONTROL_BEHAVIOR_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_CHECKBOX_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_checkbox.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_DROPDOWN_MENU_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_dropdown_menu.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_PREF_CONTROL_BEHAVIOR_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/pref_control_behavior.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_RADIO_GROUP_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_radio_group.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_SLIDER_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_slider.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_TEXTAREA_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_textarea.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_CONTROLS_SETTINGS_TOGGLE_BUTTON_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/controls/settings_toggle_button.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_EXTENSION_CONTROL_BROWSER_PROXY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/extension_control_browser_proxy.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_I18N_SETUP_M_JS"
file="i18n_setup.m.js"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_PREFS_PREFS_TYPES_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/prefs/prefs_types.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_PREFS_PREF_UTIL_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/prefs/pref_util.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_ROUTER_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/router.m.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
<include name="IDR_SETTINGS_SEARCH_SETTINGS_M_JS" <include name="IDR_SETTINGS_SEARCH_SETTINGS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_settings.m.js" file="${root_gen_dir}/chrome/browser/resources/settings/search_settings.m.js"
use_base_dir="false" use_base_dir="false"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_SETTINGS_SETTINGS_SHARED_CSS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/settings_shared_css.m.js"
use_base_dir="false"
type="BINDATA"
preprocess="true"
compress="gzip" />
<include name="IDR_SETTINGS_SETTINGS_VARS_CSS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/settings_vars_css.m.js"
use_base_dir="false"
type="BINDATA"
preprocess="true"
compress="gzip" />
<include name="IDR_SETTINGS_SETTINGS_V3_HTML" <include name="IDR_SETTINGS_SETTINGS_V3_HTML"
file="settings_v3.html" file="settings_v3.html"
type="BINDATA" /> type="BINDATA" />
......
...@@ -121,12 +121,13 @@ ...@@ -121,12 +121,13 @@
#include "chrome/browser/ui/webui/settings/printing_handler.h" #include "chrome/browser/ui/webui/settings/printing_handler.h"
#endif #endif
namespace settings {
#if !BUILDFLAG(OPTIMIZE_WEBUI) #if !BUILDFLAG(OPTIMIZE_WEBUI)
constexpr char kGeneratedPath[] = constexpr char kGeneratedPath[] =
"@out_folder@/gen/chrome/browser/resources/settings/"; "@out_folder@/gen/chrome/browser/resources/settings/";
#endif #endif
namespace settings {
// static // static
void SettingsUI::RegisterProfilePrefs( void SettingsUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
......
...@@ -96,6 +96,7 @@ js2gtest("browser_tests_js_webui") { ...@@ -96,6 +96,7 @@ js2gtest("browser_tests_js_webui") {
"settings/advanced_page_browsertest.js", "settings/advanced_page_browsertest.js",
"settings/basic_page_browsertest.js", "settings/basic_page_browsertest.js",
"settings/cr_settings_browsertest.js", "settings/cr_settings_browsertest.js",
"settings/cr_settings_v3_browsertest.js",
"settings/help_page_browsertest.js", "settings/help_page_browsertest.js",
"settings/settings_idle_load_browsertest.js", "settings/settings_idle_load_browsertest.js",
"settings/site_settings_page_browsertest.js", "settings/site_settings_page_browsertest.js",
...@@ -205,6 +206,16 @@ js2gtest("browser_tests_js_webui") { ...@@ -205,6 +206,16 @@ js2gtest("browser_tests_js_webui") {
"$root_gen_dir/chrome/test/data/webui/mock_controller.m.js", "$root_gen_dir/chrome/test/data/webui/mock_controller.m.js",
"$root_gen_dir/chrome/test/data/webui/mock_timer.m.js", "$root_gen_dir/chrome/test/data/webui/mock_timer.m.js",
"$root_gen_dir/chrome/test/data/webui/resources/list_property_update_behavior_tests.m.js", "$root_gen_dir/chrome/test/data/webui/resources/list_property_update_behavior_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/checkbox_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/controlled_button_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/controlled_radio_button_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/dropdown_menu_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/extension_controlled_indicator_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/pref_util_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/settings_slider_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/settings_textarea_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/settings_toggle_button_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/test_extension_control_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/test_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/test_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/test_store.m.js", "$root_gen_dir/chrome/test/data/webui/test_store.m.js",
"$root_gen_dir/chrome/test/data/webui/test_util.m.js", "$root_gen_dir/chrome/test/data/webui/test_util.m.js",
...@@ -299,6 +310,7 @@ group("modulize") { ...@@ -299,6 +310,7 @@ group("modulize") {
"./cr_components:modulize", "./cr_components:modulize",
"./cr_elements:modulize", "./cr_elements:modulize",
"./resources:modulize", "./resources:modulize",
"./settings:modulize",
] ]
} }
......
# Copyright 2020 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.
import("//ui/webui/resources/tools/js_modulizer.gni")
js_modulizer("modulize") {
input_files = [
"checkbox_tests.js",
"controlled_button_tests.js",
"controlled_radio_button_tests.js",
"dropdown_menu_tests.js",
"extension_controlled_indicator_tests.js",
"pref_util_tests.js",
"settings_slider_tests.js",
"settings_textarea_tests.js",
"settings_toggle_button_tests.js",
"test_extension_control_browser_proxy.js",
]
namespace_rewrites = [
"settings.ExtensionControlBrowserProxyImpl|ExtensionControlBrowserProxyImpl",
"test_util.eventToPromise|eventToPromise",
"test_util.flushTasks|flushTasks",
"MockInteractions.keyDownOn|keyDownOn",
"MockInteractions.keyUpOn|keyUpOn",
"Settings.PrefUtil.prefToString|prefToString",
"global.traceAssertionsForTesting|window.traceAssertionsForTesting",
"Settings.PrefUtil.stringToPrefValue|stringToPrefValue",
]
}
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import 'chrome://settings/settings.js';
/** @fileoverview Suite of tests for settings-checkbox. */ /** @fileoverview Suite of tests for settings-checkbox. */
suite('SettingsCheckbox', function() { suite('SettingsCheckbox', function() {
/** /**
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import 'chrome://settings/settings.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// clang-format on
suite('controlled button', function() { suite('controlled button', function() {
/** @type {ControlledButtonElement} */ /** @type {ControlledButtonElement} */
let controlledButton; let controlledButton;
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import 'chrome://settings/settings.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// clang-format on
suite('controlled radio button', function() { suite('controlled radio button', function() {
/** @type {ControlledRadioButtonElement} */ /** @type {ControlledRadioButtonElement} */
let radioButton; let radioButton;
......
// Copyright 2020 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.
/** @fileoverview Tests for shared Polymer 3 elements. */
GEN('#include "chrome/common/buildflags.h"');
// Polymer BrowserTest fixture.
GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']);
// Settings v3 resources are only available in non optimized builds.
GEN('#if !BUILDFLAG(OPTIMIZE_WEBUI)');
/** Test fixture for shared Polymer 3 elements. */
// eslint-disable-next-line no-var
var CrSettingsV3BrowserTest = class extends PolymerTest {
/** @override */
get browsePreload() {
return 'chrome://settings';
}
/** @override */
get extraLibraries() {
return [
'//third_party/mocha/mocha.js',
'//chrome/test/data/webui/mocha_adapter.js',
];
}
};
// eslint-disable-next-line no-var
var CrControlledButtonV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/controlled_button_tests.m.js';
}
};
TEST_F('CrControlledButtonV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrControlledRadioButtonV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/controlled_radio_button_tests.m.js';
}
};
TEST_F('CrControlledRadioButtonV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsCheckboxV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/checkbox_tests.m.js';
}
};
TEST_F('CrSettingsCheckboxV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsDropdownMenuV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/dropdown_menu_tests.m.js';
}
};
TEST_F('CrSettingsDropdownMenuV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsExtensionControlledIndicatorV3Test =
class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/extension_controlled_indicator_tests.m.js';
}
};
TEST_F('CrSettingsExtensionControlledIndicatorV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsPrefUtilV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/pref_util_tests.m.js';
}
};
TEST_F('CrSettingsPrefUtilV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsSliderV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/settings_slider_tests.m.js';
}
};
TEST_F('CrSettingsSliderV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsTextareaV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/settings_textarea_tests.m.js';
}
};
TEST_F('CrSettingsTextareaV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsToggleButtonV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/settings_toggle_button_tests.m.js';
}
};
TEST_F('CrSettingsToggleButtonV3Test', 'All', function() {
mocha.run();
});
GEN('#endif // !BUILDFLAG(OPTIMIZE_WEBUI)');
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import 'chrome://settings/settings.js';
// #import {assert} from 'chrome://resources/js/assert.m.js';
/** @fileoverview Suite of tests for settings-dropdown-menu. */ /** @fileoverview Suite of tests for settings-dropdown-menu. */
suite('SettingsDropdownMenu', function() { suite('SettingsDropdownMenu', function() {
/** @type {SettingsDropdownMenu} */ /** @type {SettingsDropdownMenu} */
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import {ExtensionControlBrowserProxyImpl} from 'chrome://settings/settings.js';
// #import {TestExtensionControlBrowserProxy} from 'chrome://test/settings/test_extension_control_browser_proxy.m.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// clang-format on
suite('extension controlled indicator', function() { suite('extension controlled indicator', function() {
/** @type {TestExtensionControlBrowserProxy} */ /** @type {TestExtensionControlBrowserProxy} */
let browserProxy; let browserProxy;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import {prefToString, stringToPrefValue} from 'chrome://settings/settings.js';
// clang-format on
/** @fileoverview Suite of tests for Settings.PrefUtil. */ /** @fileoverview Suite of tests for Settings.PrefUtil. */
suite('PrefUtil', function() { suite('PrefUtil', function() {
const global = function() { const global = function() {
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import 'chrome://settings/settings.js';
// #import {eventToPromise, flushTasks} from 'chrome://test/test_util.m.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {keyDownOn, keyUpOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
// clang-format on
/** @fileoverview Suite of tests for settings-slider. */ /** @fileoverview Suite of tests for settings-slider. */
suite('SettingsSlider', function() { suite('SettingsSlider', function() {
/** @type {!SettingsSliderElement} */ /** @type {!SettingsSliderElement} */
...@@ -104,7 +111,7 @@ suite('SettingsSlider', function() { ...@@ -104,7 +111,7 @@ suite('SettingsSlider', function() {
test('enforce value', function() { test('enforce value', function() {
// Test that the indicator is not present until after the pref is // Test that the indicator is not present until after the pref is
// enforced. // enforced.
indicator = slider.$$('cr-policy-pref-indicator'); let indicator = slider.$$('cr-policy-pref-indicator');
assertFalse(!!indicator); assertFalse(!!indicator);
slider.pref = { slider.pref = {
controlledBy: chrome.settingsPrivate.ControlledBy.DEVICE_POLICY, controlledBy: chrome.settingsPrivate.ControlledBy.DEVICE_POLICY,
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import 'chrome://settings/settings.js';
/** @fileoverview Suite of tests for settings-textarea. */ /** @fileoverview Suite of tests for settings-textarea. */
suite('SettingsTextarea', function() { suite('SettingsTextarea', function() {
/** @type {!SettingsTextareaElement} */ /** @type {!SettingsTextareaElement} */
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import 'chrome://settings/settings.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// clang-format on
/** @fileoverview Suite of tests for settings-toggle-button. */ /** @fileoverview Suite of tests for settings-toggle-button. */
suite('SettingsToggleButton', () => { suite('SettingsToggleButton', () => {
/** /**
...@@ -70,7 +75,7 @@ suite('SettingsToggleButton', () => { ...@@ -70,7 +75,7 @@ suite('SettingsToggleButton', () => {
}); });
test('fires a single change event per tap', () => { test('fires a single change event per tap', () => {
counter = 0; let counter = 0;
testElement.addEventListener('change', () => { testElement.addEventListener('change', () => {
++counter; ++counter;
}); });
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js';
/** @implements {settings.ExtensionControlBrowserProxy} */ /** @implements {settings.ExtensionControlBrowserProxy} */
class TestExtensionControlBrowserProxy extends TestBrowserProxy { /* #export */ class TestExtensionControlBrowserProxy extends TestBrowserProxy {
constructor() { constructor() {
super([ super([
'disableExtension', 'disableExtension',
......
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