tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit c27e0af2eca2ccddf4b4c89552b8bb863d61060c
parent 5dff3104946def02199c3f2f43cbf5e932273e51
Author: Keith Cirkel <keithamus@users.noreply.github.com>
Date:   Wed,  1 Oct 2025 08:46:36 +0000

Bug 1990014 - Re-order dialog attr changed steps so that cleanup steps always occur r=smaug,dom-core

This is causing assertion failures due to the Dialog not being removed
from the open dialogs list when it is not open.

Differential Revision: https://phabricator.services.mozilla.com/D265771

Diffstat:
Mdom/html/HTMLDialogElement.cpp | 12++++++------
Atesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-setup-cleanup-crash.html | 19+++++++++++++++++++
Atesting/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/showmodal-frame.html | 8++++++++
3 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp @@ -548,17 +548,17 @@ void HTMLDialogElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, MOZ_ASSERT(GetBoolAttr(nsGkAtoms::open) == isOpen); SetStates(ElementState::OPEN, isOpen); - // 3. If element's node document is not fully active, then return. - if (!OwnerDoc()->IsFullyActive()) { - return; - } - - // 4. If value is null and oldValue is not null, then run the dialog cleanup + // 3. If value is null and oldValue is not null, then run the dialog cleanup // steps given element. if (!isOpen && wasOpen) { CleanupSteps(); } + // 4. If element's node document is not fully active, then return. + if (!OwnerDoc()->IsFullyActive()) { + return; + } + // 5. If element is not connected, then return. if (!IsInComposedDoc()) { return; diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-setup-cleanup-crash.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-setup-cleanup-crash.html @@ -0,0 +1,19 @@ +<!doctype html> +<link rel="author" href="mailto:wpt@keithcirkel.co.uk" /> +<link rel="help" href="https://html.spec.whatwg.org/#the-dialog-element" /> + +<!-- This test passes if it does not crash. --> + +<iframe src="./resources/showmodal-frame.html"></iframe> + +<script> + new Promise((resolve) => (window.loaded = resolve)).then(() => { + const iframe = document.body.querySelector("iframe"); + const iframeDoc = iframe.contentDocument; + iframe.remove(); + iframeDoc.querySelector("dialog").close(); + iframeDoc.querySelector("dialog").setAttribute("open", ""); + document.body.append(iframe); + iframeDoc.querySelector("dialog").show(); + }); +</script> diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/showmodal-frame.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/showmodal-frame.html @@ -0,0 +1,8 @@ +<!doctype html> + +<dialog id="dialog"></dialog> + +<script> +dialog.showModal(); +window.onload = parent.parent.loaded(); +</script>