-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
html/semantics/interactive-elements/the-dialog-element/centering-iframe.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>dialog element centered frame</title> | ||
<style> | ||
html { | ||
writing-mode: {{GET[html-writing-mode]}} | ||
} | ||
|
||
#container { | ||
writing-mode: {{GET[container-writing-mode]}} | ||
} | ||
|
||
dialog { | ||
writing-mode: {{GET[dialog-writing-mode]}}; | ||
border: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
</style> | ||
|
||
<div id="container"> | ||
<dialog style="width: 20px; height: 10px;">X</dialog> <!-- sync width and height with centering.html --> | ||
</div> | ||
|
||
<script> | ||
"use strict"; | ||
document.querySelector("dialog").showModal(); | ||
</script> |
51 changes: 51 additions & 0 deletions
51
html/semantics/interactive-elements/the-dialog-element/centering.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>dialog element: centered alignment</title> | ||
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]"> | ||
<link rel=help href="https://html.spec.whatwg.org/multipage/#centered-alignment"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
// Be sure to sync with centering-iframe.html | ||
const DIALOG_WIDTH = 20; | ||
const DIALOG_HEIGHT = 10; | ||
|
||
testDialogCentering("horizontal-tb", "", "", "tall viewport", 40, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2); | ||
testDialogCentering("horizontal-tb", "", "", "wide viewport", 100, 40, "top", 40 / 2 - DIALOG_HEIGHT / 2); | ||
testDialogCentering("horizontal-tb", "", "", "square viewport", 100, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2); | ||
testDialogCentering("horizontal-tb", "", "", "dialog and viewport match", DIALOG_WIDTH, DIALOG_HEIGHT, "top", 0); | ||
testDialogCentering("horizontal-tb", "", "", "dialog bigger than viewport", 100, DIALOG_HEIGHT / 2, "top", 0); | ||
|
||
testDialogCentering("vertical-rl", "", "", "tall viewport", 40, 100, "left", 40 / 2 - DIALOG_WIDTH / 2); | ||
testDialogCentering("vertical-lr", "", "", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2); | ||
testDialogCentering("vertical-lr", "", "", "dialog bigger than viewport", DIALOG_WIDTH / 2, 100, "right", 0); | ||
|
||
testDialogCentering("vertical-rl", "", "horizontal-tb", "tall viewport", 40, 100, "left", 40 / 2 - DIALOG_WIDTH / 2); | ||
testDialogCentering("vertical-lr", "", "horizontal-tb", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2); | ||
testDialogCentering("vertical-lr", "", "horizontal-tb", "dialog bigger than viewport", DIALOG_WIDTH / 2, 100, "right", 0); | ||
|
||
testDialogCentering("horizontal-tb", "vertical-rl", "", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2); | ||
testDialogCentering("vertical-rl", "horizontal-tb", "", "tall viewport", 40, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2); | ||
|
||
testDialogCentering("horizontal-tb", "vertical-rl", "horizontal-tb", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2); | ||
testDialogCentering("vertical-rl", "horizontal-tb", "vertical-rl", "tall viewport", 40, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2); | ||
|
||
function testDialogCentering(writingMode, containerWritingMode, dialogWritingMode, label, iframeWidth, iframeHeight, property, numericValue) { | ||
async_test(t => { | ||
const iframe = document.createElement("iframe"); | ||
iframe.src = `centering-iframe.sub.html?html-writing-mode=${writingMode}&container-writing-mode=${containerWritingMode}&dialog-writing-mode=${dialogWritingMode}`; | ||
iframe.width = iframeWidth; | ||
iframe.height = iframeHeight; | ||
iframe.onload = t.step_func_done(() => { | ||
const dialog = iframe.contentDocument.querySelector("dialog"); | ||
assert_equals(iframe.contentWindow.getComputedStyle(dialog)[property], numericValue + "px"); | ||
}); | ||
document.body.appendChild(iframe); | ||
}, writingMode + (containerWritingMode ? ` (container ${containerWritingMode})` : "") + | ||
(dialogWritingMode ? ` (dialog ${dialogWritingMode})` : "") + `: ${label}`); | ||
} | ||
</script> |