diff --git a/layout/style/res/html.css b/layout/style/res/html.css
index 3fc451c0361d..ff7bd3ce4d13 100644
--- a/layout/style/res/html.css
+++ b/layout/style/res/html.css
@@ -828,6 +828,7 @@ dialog {
padding: 1em;
background: white;
width: -moz-fit-content;
+ height: -moz-fit-content;
}
dialog:not([open]) {
@@ -836,6 +837,13 @@ dialog:not([open]) {
dialog:-moz-modal-dialog {
-moz-top-layer: top !important;
+ /* This is a temporary solution until the relevant CSSWG issues are resolved */
+ position: fixed;
+ max-height: 100vh;
+ max-width: 100vw;
+ top: 50%;
+ transform: translateY(-50%);
+ overflow: auto;
}
/* https://html.spec.whatwg.org/#flow-content-3 */
diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/abspos-dialog-layout.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/abspos-dialog-layout.html.ini
index 6cfa67fcebc4..d9eae444a841 100644
--- a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/abspos-dialog-layout.html.ini
+++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/abspos-dialog-layout.html.ini
@@ -1,34 +1,11 @@
[abspos-dialog-layout.html]
- [showModal() should center in the viewport]
- expected: FAIL
-
- [The dialog is a positioned element, so the top and bottom should not have style auto.]
- expected: FAIL
-
- [Dialog should be recentered if showModal() is called after close()]
- expected: FAIL
-
- [Dialog should not recenter on relayout.]
- expected: FAIL
-
- [A tall dialog should be positioned at the top of the viewport.]
- expected: FAIL
-
+ prefs:[dom.dialog_element.enabled:true]
[The dialog should be centered regardless of the presence of a horizontal scrollbar.]
expected: FAIL
[Centering should work when dialog is inside positioned containers.]
expected: FAIL
- [A centered dialog's position should survive becoming display:none temporarily.]
- expected: FAIL
-
- [Dialog should lose centering when removed from the document.]
- expected: FAIL
-
- [Dialog's specified position should survive after close() and showModal().]
- expected: FAIL
-
[Dialog should be recentered if showModal() is called after removing 'open'.]
expected: FAIL