From 5eb9cadb0876eaa1994ec65a96ed69931a60deca Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Wed, 19 Jun 2019 17:39:25 -0400 Subject: [PATCH] Fix conformance violations --- build-system/conformance-config.textproto | 1 + extensions/amp-auto-ads/0.1/anchor-ad-strategy.js | 12 ++++++------ extensions/amp-date-picker/0.1/dates-list.js | 6 ++++-- .../allowed-attribute-mutation-entry.js | 4 +--- extensions/amp-geo/0.1/amp-geo.js | 4 +++- extensions/amp-story/1.0/page-advancement.js | 7 ++++--- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/build-system/conformance-config.textproto b/build-system/conformance-config.textproto index 13e63537dde9..c2f275becabf 100644 --- a/build-system/conformance-config.textproto +++ b/build-system/conformance-config.textproto @@ -258,6 +258,7 @@ requirement: { whitelist: 'src/web-worker/web-worker.js' # Allowing violations in ads code for now. # We would have to fix this to property obfuscated the 3p frame code. + whitelist: '3p/iframe-messaging-client.js' whitelist: 'ads/google/deprecated_doubleclick.js' whitelist: 'ads/google/imaVideo.js' } diff --git a/extensions/amp-auto-ads/0.1/anchor-ad-strategy.js b/extensions/amp-auto-ads/0.1/anchor-ad-strategy.js index b7d34de47c80..f8ce6f07cc4f 100644 --- a/extensions/amp-auto-ads/0.1/anchor-ad-strategy.js +++ b/extensions/amp-auto-ads/0.1/anchor-ad-strategy.js @@ -88,9 +88,9 @@ export class AnchorAdStrategy { * @private */ isFilledAnchorAdEnabled_() { - return (this.configObj_['optInStatus'] || []).includes( - OptInStatus.OPT_IN_STATUS_ANCHOR_ADS - ); + return user() + .assertArray(this.configObj_['optInStatus'] || []) + .includes(OptInStatus.OPT_IN_STATUS_ANCHOR_ADS); } /** @@ -98,9 +98,9 @@ export class AnchorAdStrategy { * @private */ isNoFillAnchorAdEnabled_() { - return (this.configObj_['optInStatus'] || []).includes( - OptInStatus.OPT_IN_STATUS_NO_FILL_ANCHOR_ADS - ); + return user() + .assertArray(this.configObj_['optInStatus'] || []) + .includes(OptInStatus.OPT_IN_STATUS_NO_FILL_ANCHOR_ADS); } /** diff --git a/extensions/amp-date-picker/0.1/dates-list.js b/extensions/amp-date-picker/0.1/dates-list.js index 9cc342e4c6df..22736ac2a688 100644 --- a/extensions/amp-date-picker/0.1/dates-list.js +++ b/extensions/amp-date-picker/0.1/dates-list.js @@ -80,7 +80,9 @@ export class DatesList { } } const rruleDates = this.rrulestrs_ - .map(rrule => rrule.after(date)) + .map(rrule => { + return /** @type {!RRule} */ (rrule).after(date, undefined); + }) .filter(Boolean); firstDatesAfter.concat(rruleDates); @@ -138,7 +140,7 @@ export class DatesList { /** * Tries to parse a string into an RRULE object. * @param {string} str A string which represents a repeating date RRULE spec. - * @return {?JsonObject} + * @return {?RRule} */ function tryParseRrulestr(str) { try { diff --git a/extensions/amp-experiment/1.0/attribute-allow-list/allowed-attribute-mutation-entry.js b/extensions/amp-experiment/1.0/attribute-allow-list/allowed-attribute-mutation-entry.js index 04fdba8effeb..9236e0de726c 100644 --- a/extensions/amp-experiment/1.0/attribute-allow-list/allowed-attribute-mutation-entry.js +++ b/extensions/amp-experiment/1.0/attribute-allow-list/allowed-attribute-mutation-entry.js @@ -30,9 +30,7 @@ export class AllowedAttributeMutationEntry { * @return {boolean} */ validate(mutationRecord) { - if (mutationRecord['value']) { - return true; - } + return !!mutationRecord['value']; } /** diff --git a/extensions/amp-geo/0.1/amp-geo.js b/extensions/amp-geo/0.1/amp-geo.js index 30f703f3042a..a8107fe2a50d 100644 --- a/extensions/amp-geo/0.1/amp-geo.js +++ b/extensions/amp-geo/0.1/amp-geo.js @@ -343,7 +343,9 @@ export class AmpGeo extends AMP.BaseElement { const {classList} = body; // Always remove the pending class classesToRemove.push('amp-geo-pending'); - classesToRemove.forEach(toRemove => classList.remove(toRemove)); + classesToRemove.forEach(toRemove => { + /** @type {!DOMTokenList} */ (classList).remove(toRemove); + }); // add the new classes to classesToAdd.forEach(toAdd => classList.add(toAdd)); diff --git a/extensions/amp-story/1.0/page-advancement.js b/extensions/amp-story/1.0/page-advancement.js index f94c4ce01270..87a0fe9cd556 100644 --- a/extensions/amp-story/1.0/page-advancement.js +++ b/extensions/amp-story/1.0/page-advancement.js @@ -541,9 +541,10 @@ class ManualAdvancement extends AdvancementConfig { */ isHandledByEmbeddedComponent_(event, pageRect) { const target = dev().assertElement(event.target); - const inExpandedMode = - this.storeService_.get(StateProperty.INTERACTIVE_COMPONENT_STATE) - .state === EmbeddedComponentState.EXPANDED; + const stored = /** @type {InteractiveComponentDef} */ (this.storeService_.get( + StateProperty.INTERACTIVE_COMPONENT_STATE + )); + const inExpandedMode = stored.state === EmbeddedComponentState.EXPANDED; return ( inExpandedMode ||