Serve Amazon ads in a SafeFrame
kmjennison opened this issue · 0 comments
Adblock Plus is erroneously blocking our site's ads even after users whitelist the site. This behavior is a bug in Adblock Plus driven by a bug in Chrome. See this ABP issue filed by a Tab for a Cause user: https://issues.adblockplus.org/ticket/7336
ABP is addressing the issue, but we want a stopgap fix rather than wait.
Our ads aren't susceptible to this bug if the ad iframes don't use the srcdoc
attribute, which Google Ad Manager appears to use for all "friendly iframes". To avoid the srcdoc
attribute, we can use SafeFrames for ad creative.
This PR is a workaround to make Amazon TAM ads work in a SafeFrame. It does so by:
- having the ad creative post a message to our site with the ad ID
- rendering the ad into a mock document on the top site
- passing the document HTML back to the SafeFrame, where it can render the document
This code is only a quick workaround and is likely unstable. We should revert to the original ad creative when the ABP bug is resolved