Commit 058af229 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Print Preview: Add some null checks for customMargins.

If the printing sticky settings somehow ended up with
"customMargins:null", then Print Preview code that assumes customMargins
values are always valid will fail while reading properties of null.

Change-Id: I8fb297e58050bf78605931c8aafb390035f486e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102083
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750303}
parent 0f187695
...@@ -171,7 +171,7 @@ Polymer({ ...@@ -171,7 +171,7 @@ Polymer({
/** @private */ /** @private */
onMarginSettingsChange_() { onMarginSettingsChange_() {
const margins = this.getSettingValue('customMargins'); const margins = this.getSettingValue('customMargins');
if (margins.marginTop === undefined) { if (!margins || margins.marginTop === undefined) {
// This may be called when print preview model initially sets the // This may be called when print preview model initially sets the
// settings. It sets custom margins empty by default. // settings. It sets custom margins empty by default.
return; return;
...@@ -204,8 +204,8 @@ Polymer({ ...@@ -204,8 +204,8 @@ Polymer({
if (this.state === State.READY && this.resetMargins_ === null) { if (this.state === State.READY && this.resetMargins_ === null) {
// Don't reset margins if there are sticky values. Otherwise, set them // Don't reset margins if there are sticky values. Otherwise, set them
// to the document margins when the user selects custom margins. // to the document margins when the user selects custom margins.
this.resetMargins_ = const margins = this.getSettingValue('customMargins');
this.getSettingValue('customMargins').marginTop === undefined; this.resetMargins_ = !margins || margins.marginTop === undefined;
} }
}, },
......
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