New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Story Player should set parent origin if current window origin is null #28225
Comments
You can use the parent origin but this needs to be guarded by being able to access it. The iframe could also be sandboxed without The question here is whether checking the origin is actually desired? A check like |
I'm not very familiar with this part of the AMP codebase, we're trying to work with the amphtml/extensions/amp-viewer-integration/0.1/messaging/messaging.js Lines 88 to 96 in fd86263
The issue comes from how the Story player retrieves the origin: amphtml/src/amp-story-player/amp-story-player-impl.js Lines 459 to 465 in fd86263
Replacing this with |
Relevant: Which line of code is the one that is failing today? |
Thank you Gabriel for helping on our issue. I also want to mention that in our use case, window.parent.location.origin is also null, so not sure if fall back to parent origin will work here. |
Always passing |
OK, this is really quite edge-casey. I missed that it is the parent here who doesn't have a proper origin. Looks like this line needs an do add |
Sorry, late to the party here. But like @gmajoulet mentioned, this is a bug on the player side. We were getting the origin through |
After playing around with this a bit more I found an issue with the messaging / viewer-integration code:
amphtml/extensions/amp-viewer-integration/0.1/amp-viewer-integration.js Lines 122 to 124 in 471bbb9
amphtml/extensions/amp-viewer-integration/0.1/messaging/messaging.js Lines 81 to 85 in 471bbb9
The A solution here would be to pass a |
Null origin inside srcdoc was pretty surprizing to me, but after some digging, it makes sense and I think we can just use
Browser support should be checked though. MDN says not all browsers are supported, but I've tested on Safari which is listed as not supported and it works for me: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/origin |
Thank you for taking a look at this @molnarg !
|
Story Player fails to set up the communication with its Story when in a
<iframe srcdoc="<playerhtml>">
context.The
location.href
that the player gets in this context isabout:srcdoc
, and sets the#origin=...
parameter to an invalidabout:srcdoc
value.If we detect that the
window.location.origin
isnull
, we should fallback to something else. Maybewindow.parent.location.origin
? I don't know if that would work. Setting#origin=*
works but might not be the best fix.Repro case (replacing
SOME_STORY_URL
with an actual Story URL):cc @ampproject/wg-stories @Enriqe
The text was updated successfully, but these errors were encountered: