Skip to content

Set iframe sandbox flags before child navigable creation#12360

Merged
domfarolino merged 1 commit intowhatwg:mainfrom
shannonbooth:iframe-sandbox-flags
Apr 14, 2026
Merged

Set iframe sandbox flags before child navigable creation#12360
domfarolino merged 1 commit intowhatwg:mainfrom
shannonbooth:iframe-sandbox-flags

Conversation

@shannonbooth
Copy link
Copy Markdown
Member

@shannonbooth shannonbooth commented Apr 12, 2026

The initial about:blank document inherits sandbox flags when the child navigable is created. Parse the iframe sandbox attribute first so the initial child document gets the correct sandbox state.

(See WHATWG Working Mode: Changes for more details.)


/iframe-embed-object.html ( diff )

The initial about:blank document inherits sandbox flags when the
child navigable is created. Parse the iframe sandbox attribute first
so the initial child document gets the correct sandbox state.
Copy link
Copy Markdown
Member

@domfarolino domfarolino left a comment

Choose a reason for hiding this comment

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

Nice catch, it's surprising that this was overlooked. I edited the OP to mark Gecko as "already implemented" with the exception of the contextual fragment edge case you linked to, since Gecko implements this correctly in the general case 1. Anyways, I think this LGTM.

Footnotes

  1. For example, if you load data:text/html,<iframe id=iframe sandbox=allow-same-origin></iframe> in the address bar and then try and run iframe.contentDocument.write('<script>console.log(1)</script>') in the DevTools, the script doesn't run. Gecko only seems to fail the contextual fragment edge case above, so I think that's worth calling out as an exception.

@domfarolino domfarolino merged commit 3fd7f35 into whatwg:main Apr 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants