Skip to content

doc[iframe]: remove HTMLDialogElement.showModal from allow-popups - #39580

Merged
chrisdavidmills merged 2 commits into
mdn:mainfrom
samuel871211:iframe
May 20, 2025
Merged

chrisdavidmills merged 2 commits into
mdn:mainfrom
samuel871211:iframe

Conversation

@samuel871211

Copy link
Copy Markdown
Contributor

Description

Motivation

HTMLDialogElement.showModal does not create a new browsing context. Thus, it's not controlled by the allow-popups.

Test locally with Chrome v136 and Safari v18.3.1, dialog can open with allow-popups not set.

http://localhost:5000/

<html>
  <head></head>
  <body>
    <h1>5000</h1>
    <div>5000sandbox.html</div>
    <iframe src="http://localhost:5000/sandbox" sandbox="allow-scripts"></iframe>
  </body>
</html>

http://localhost:5000/sandbox

<html>
  <head></head>
  <body>
    <h1>5000sandbox</h1>
    <h3>allow-popups</h3>
    <div>
      <dialog id="dialog">
        <div>dialog content</div>
        <button id="dialogCloseButton">close dialog</button>
      </dialog>
      <button id="dialogOpenButton">open dialog</button>
      <a target="_blank" href="https://example.com/">open example.com</a>
      <script>
        open("https://example.com/");
        const dialogElement = document.getElementById("dialog");
        document.getElementById("dialogOpenButton")?.addEventListener('click', () => {
          dialogElement.showModal();
        });
        document.getElementById("dialogCloseButton")?.addEventListener('click', () => {
          dialogElement.close();
        });
      </script>
    </div>
  </body>
</html>

1747732820158@2x

Additional details

https://html.spec.whatwg.org/multipage/browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag

Related issues and pull requests

Relates to #39556

@samuel871211
samuel871211 requested review from a team and chrisdavidmills and removed request for a team May 20, 2025 09:27
@github-actions github-actions Bot added Content:HTML Hypertext Markup Language docs size/xs [PR only] 0-5 LoC changed labels May 20, 2025
@github-actions

github-actions Bot commented May 20, 2025 •

Copy link
Copy Markdown
Contributor

Preview URLs

(comment last updated: 2025-05-20 13:55:27)

@chrisdavidmills chrisdavidmills left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good spot, thanks @samuel871211. I've tweaked the grammar a bit so it still works with that item removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:HTML Hypertext Markup Language docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants