Skip to content

Commit

Permalink
Print Preview: Polymer 3 cleanups
Browse files Browse the repository at this point in the history
- 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/+/1919908
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716470}
  • Loading branch information
rbpotter authored and Commit Bot committed Nov 19, 2019
1 parent f73dbd7 commit 85939fc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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));
2 changes: 1 addition & 1 deletion chrome/browser/resources/print_preview/ui/throbber_css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
5 changes: 1 addition & 4 deletions chrome/browser/ui/webui/print_preview/print_preview_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down
23 changes: 10 additions & 13 deletions chrome/test/data/webui/print_preview/select_behavior_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -23,20 +23,17 @@ suite(select_behavior_test.suiteName, function() {

/** @override */
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({
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],

onProcessSelectChange: function(value) {
Expand Down

0 comments on commit 85939fc

Please sign in to comment.