Skip to content

Commit a7b7cf1

Browse files
committed
Add defensive check around ad iframe existence before checking contentWindow. (#40287)
(cherry picked from commit c5d994e)
1 parent 1126759 commit a7b7cf1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ export class AmpAdNetworkAdsenseImpl extends AmpA4A {
590590
* @return {boolean} True if the source of the message matches the ad iframe.
591591
*/
592592
checkIfClearCookiePostMessageHasValidSource_(event) {
593-
return event.source == devAssert(this.iframe.contentWindow);
593+
return this.iframe && event.source == this.iframe.contentWindow;
594594
}
595595

596596
/** @override */

extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
14191419
* @return {boolean} True if the source of the message matches the ad iframe.
14201420
*/
14211421
checkIfClearCookiePostMessageHasValidSource_(event) {
1422-
return event.source == devAssert(this.iframe.contentWindow);
1422+
return this.iframe && event.source == this.iframe.contentWindow;
14231423
}
14241424

14251425
/**

0 commit comments

Comments
 (0)