amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

cross-domain iframe fail to get amp context API

Open bruscantini opened this issue 8 years ago • 6 comments

What's the issue?

This issue relates to cases where attempts to access the amp context API from a nested 3rd party iframe (specifically DFP) are unsuccessful. Utilizing #6829 works MOST of the time. However there are instances where the "name" property of the DFP iframe is not a JSON string as the solution in #6829 expects it to be. Therefore, the ad creative has no access to the 'ampcontextVersion', 'sourceUrl', etc.

How do we reproduce the issue?

As I've said, the issue intermittent, but happens probably 20% of the time. Using the following URL to test, we can see that on a failure case, window.name returns something like:

"google_ads_iframe_/24156345/mobile_twist/article_amp/inline1_0"

A successful case has window.name return something like this (I omit some values for clarity):

"{ "host":"d-3447962333352148365.ampproject.net", "type":"ix","count":4,"attributes":{"ixId":"218918","slot":"/24156345/mobile_twist/article_amp/inline1","ampSlotIndex":"0","width":320,"height":50,"_context":{"ampcontextVersion":"1510956201635","ampcontextFilepath":"https://3p.ampproject.net/1510956201635/ampcontext-v0.js","sourceUrl":"http://www.twistmagazine.com/posts/tommy-dorfman-13-reasons-why-career-134029.amp"},"type":"ix"}}"

Also notice how the "ampcontextVersion" property is actually nested within attributes._context in the JSON. This is opposed to what #6829 says where it should be at the top level of the JSON string returned by window.context inside the 3P iframe.

Test URL: http://www.twistmagazine.com/posts/tommy-dorfman-13-reasons-why-career-134029.amp

Step 1: Open the url in a mobile environment. Step 2: Scroll down to trigger the amp ad to load Step 3: Use dev tools to see the name property of the DFP iframes.

Why the inconsistency? Is #6829 flawed or is DFP not being implemented correctly? I notice that, in successful case, the DFP tags are GPT Light tags. On fail cases, GPT Light (Glade) is not on the page.

What browsers are affected?

All browsers

Which AMP version is affected?

Amp version: 1510956201635

bruscantini avatar Dec 07 '17 07:12 bruscantini

This issue hasn't been updated in awhile. @bradfrizzell Do you have any updates?

ampprojectbot avatar Jun 05 '18 10:06 ampprojectbot

This issue hasn't been updated in awhile. @bradfrizzell Do you have any updates?

ampprojectbot avatar Sep 11 '18 11:09 ampprojectbot

This issue hasn't been updated in awhile. @bradfrizzell Do you have any updates?

ampprojectbot avatar Dec 12 '18 10:12 ampprojectbot

I am getting similiar behaviour on version 1912201827130 but the value on window.name is amp_iframe1

massawho avatar Jan 07 '20 14:01 massawho

/cc @ampproject/wg-ads

mrjoro avatar Jan 10 '20 16:01 mrjoro

I believe we have a resolution on Slack. Feel free to reopen if you don't think so. @massa1240

powerivq avatar Mar 05 '20 22:03 powerivq