Skip to content

Use unique iframe names based on unique domain#2955

Merged
jridgewell merged 3 commits intoampproject:masterfrom
jridgewell:3p-frame-postMessage-unique-domain
Apr 21, 2016
Merged

Use unique iframe names based on unique domain#2955
jridgewell merged 3 commits intoampproject:masterfrom
jridgewell:3p-frame-postMessage-unique-domain

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

Browsers are weird. If an iframe has a name attribute, it’s window
will be cached. When you click a link, then go back, it will insert the
same src window into the iframe regardless of a different src.

Well, that hurts us since we generate a unique domain to load 3p
frames. We’ll continue to use an old domain’s window, even though the
src points to a new domain. Worse, when we post messages to the 3p
frame, we will send it with an origin parsed from the src attribute
even though that is not the real URL of the frame’s window.

Fixes #2943.

Browsers are weird. If an iframe has a `name` attribute, it’s window
will be cached. When you click a link, then go back, it will insert the
**same** src window into the iframe regardless of a different `src`.

Well, that hurts us since we generate a unique domain to load 3p
frames. We’ll continue to use an old domain’s window, even though the
src points to a new domain. Worse, when we post messages to the 3p
frame, we will send it with an origin parsed from the `src` attribute
even though that is not the real URL of the frame’s window.

Fixes ampproject#2943
@cramforce
Copy link
Copy Markdown
Member

Thanks! Please add a test.

@jridgewell
Copy link
Copy Markdown
Contributor Author

Added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be really good to hard code the actual name string in a test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@jridgewell jridgewell force-pushed the 3p-frame-postMessage-unique-domain branch 2 times, most recently from 677468e to da80c87 Compare April 21, 2016 01:17
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😔

@cramforce
Copy link
Copy Markdown
Member

LGTM

@jridgewell jridgewell force-pushed the 3p-frame-postMessage-unique-domain branch from da80c87 to 29a9b3d Compare April 21, 2016 18:35
@jridgewell jridgewell merged commit f94fd1a into ampproject:master Apr 21, 2016
@jridgewell jridgewell deleted the 3p-frame-postMessage-unique-domain branch April 21, 2016 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants