Commit 85939fcc authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Polymer 3 cleanups

- Use Polymer 3 syntax for custom elements created/defined in tests.
- Remove assetpath="chrome://resources/", which is automatically
added by the autogeneration code for style modules, but does not
make sense for modules inside of Print Preview.
- Remove unused generated_path variable
- Rename bundled Print Preview JS resource as PRINT_PREVIEW_ROLLUP_JS
to indicate that this file was generated by rollup.

Bug: 1012574
Change-Id: I37fe3228b1e6b1811b8bfed6abf4f4784d5e7587
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1919908Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716470}
parent f73dbd74
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<release seq="1"> <release seq="1">
<includes> <includes>
<include name="IDR_PRINT_PREVIEW_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\print_preview\vulcanized.html" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" /> <include name="IDR_PRINT_PREVIEW_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\print_preview\vulcanized.html" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" />
<include name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_JS" file="${root_gen_dir}\chrome\browser\resources\print_preview\print_preview.js" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" /> <include name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_ROLLUP_JS" file="${root_gen_dir}\chrome\browser\resources\print_preview\print_preview.js" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" />
</includes> </includes>
</release> </release>
</grit> </grit>
...@@ -10,6 +10,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun ...@@ -10,6 +10,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
const template = document.createElement('template'); const template = document.createElement('template');
template.innerHTML = ` template.innerHTML = `
<dom-module id="print-preview-shared" assetpath="chrome://resources/">{__html_template__}</dom-module> <dom-module id="print-preview-shared">{__html_template__}</dom-module>
`; `;
document.body.appendChild(template.content.cloneNode(true)); document.body.appendChild(template.content.cloneNode(true));
...@@ -6,6 +6,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun ...@@ -6,6 +6,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
const template = document.createElement('template'); const template = document.createElement('template');
template.innerHTML = ` template.innerHTML = `
<dom-module id="throbber" assetpath="chrome://resources/">{__html_template__}</dom-module> <dom-module id="throbber">{__html_template__}</dom-module>
`; `;
document.body.appendChild(template.content.cloneNode(true)); document.body.appendChild(template.content.cloneNode(true));
...@@ -403,13 +403,10 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) { ...@@ -403,13 +403,10 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
source->EnableReplaceI18nInJS(); source->EnableReplaceI18nInJS();
#if BUILDFLAG(OPTIMIZE_WEBUI) #if BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("print_preview.js", source->AddResourcePath("print_preview.js",
IDR_PRINT_PREVIEW_PRINT_PREVIEW_JS); IDR_PRINT_PREVIEW_PRINT_PREVIEW_ROLLUP_JS);
source->SetDefaultResource(IDR_PRINT_PREVIEW_VULCANIZED_HTML); source->SetDefaultResource(IDR_PRINT_PREVIEW_VULCANIZED_HTML);
#else #else
// Add all Print Preview resources. // Add all Print Preview resources.
std::string generated_path =
"@out_folder@/gen/chrome/browser/resources/print_preview/";
for (size_t i = 0; i < kPrintPreviewResourcesSize; ++i) { for (size_t i = 0; i < kPrintPreviewResourcesSize; ++i) {
std::string path = kPrintPreviewResources[i].name; std::string path = kPrintPreviewResources[i].name;
if (path.rfind(kGeneratedPath, 0) == 0) { if (path.rfind(kGeneratedPath, 0) == 0) {
......
...@@ -330,14 +330,12 @@ export function triggerInputEvent(inputElement, input, parentElement) { ...@@ -330,14 +330,12 @@ export function triggerInputEvent(inputElement, input, parentElement) {
} }
export function setupTestListenerElement() { export function setupTestListenerElement() {
const domModule = document.createElement('dom-module');
domModule.setAttribute('id', 'test-listener-element');
domModule.appendChild(document.createElement('template'));
document.body.appendChild(domModule);
Polymer({ Polymer({
is: 'test-listener-element', is: 'test-listener-element',
behaviors: [WebUIListenerBehavior], behaviors: [WebUIListenerBehavior],
}); });
const testElement = document.createElement('test-listener-element');
document.body.appendChild(testElement);
} }
/** @return {!DestinationStore} */ /** @return {!DestinationStore} */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import {SelectBehavior} from 'chrome://print/print_preview.js'; import {SelectBehavior} from 'chrome://print/print_preview.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {eventToPromise} from 'chrome://test/test_util.m.js'; import {eventToPromise} from 'chrome://test/test_util.m.js';
window.select_behavior_test = {}; window.select_behavior_test = {};
...@@ -23,20 +23,17 @@ suite(select_behavior_test.suiteName, function() { ...@@ -23,20 +23,17 @@ suite(select_behavior_test.suiteName, function() {
/** @override */ /** @override */
setup(function() { setup(function() {
document.body.innerHTML = `
<dom-module id="test-select">
<template>
<select value="{{selectedValue::change}}">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</template>
</dom-module>
`;
Polymer({ Polymer({
is: 'test-select', is: 'test-select',
_template: html`
<select value="{{selectedValue::change}}">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
`,
behaviors: [SelectBehavior], behaviors: [SelectBehavior],
onProcessSelectChange: function(value) { onProcessSelectChange: function(value) {
......
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