Skip to content

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

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

Merged
merged 2 commits into from
May 20, 2025

Conversation

samuel871211
Copy link
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 a review from a team as a code owner May 20, 2025 09:27
@samuel871211 samuel871211 requested review from 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
Copy link
Contributor

github-actions bot commented May 20, 2025

Preview URLs

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

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

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.

@chrisdavidmills chrisdavidmills merged commit 11da1e1 into mdn:main May 20, 2025
8 checks passed
@samuel871211 samuel871211 deleted the iframe branch May 20, 2025 14:01
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