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 @@
<release seq="1">
<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_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>
</release>
</grit>
......@@ -10,6 +10,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
const template = document.createElement('template');
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));
......@@ -6,6 +6,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
const template = document.createElement('template');
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));
......@@ -403,13 +403,10 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
source->EnableReplaceI18nInJS();
#if BUILDFLAG(OPTIMIZE_WEBUI)
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);
#else
// 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) {
std::string path = kPrintPreviewResources[i].name;
if (path.rfind(kGeneratedPath, 0) == 0) {
......
......@@ -330,14 +330,12 @@ export function triggerInputEvent(inputElement, input, parentElement) {
}
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({
is: 'test-listener-element',
behaviors: [WebUIListenerBehavior],
});
const testElement = document.createElement('test-listener-element');
document.body.appendChild(testElement);
}
/** @return {!DestinationStore} */
......
......@@ -4,7 +4,7 @@
import {SelectBehavior} from 'chrome://print/print_preview.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';
window.select_behavior_test = {};
......@@ -23,20 +23,17 @@ suite(select_behavior_test.suiteName, function() {
/** @override */
setup(function() {
document.body.innerHTML = `
<dom-module id="test-select">
<template>
Polymer({
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>
</template>
</dom-module>
`;
`,
Polymer({
is: 'test-select',
behaviors: [SelectBehavior],
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