Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Geolocation Element: display style validation</title>
<link
rel="help"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
function createGeolocationElementWithStyle(displayValue) {
const element = document.createElement("geolocation");
element.style.display = displayValue;
document.body.appendChild(element);
return element;
}
const testCases = [
["block", ""],
["inline-block", ""],
["flex", ""],
["inline-flex", ""],
["inline", "style_invalid"],
["contents", "style_invalid"],
["inline-table", "style_invalid"],
["list-item", "style_invalid"],
["ruby", "style_invalid"],
["ruby-text", "style_invalid"],
["table", "style_invalid"],
["table-caption", "style_invalid"],
["table-cell", "style_invalid"],
["table-column", "style_invalid"],
["table-column-group", "style_invalid"],
["table-footer-group", "style_invalid"],
["table-header-group", "style_invalid"],
["table-row", "style_invalid"],
["table-row-group", "style_invalid"],
];
for (const [displayValue, expectedInvalidReason] of testCases) {
promise_test(async (t) => {
const element = createGeolocationElementWithStyle(displayValue);
// Ensure the element is removed from the DOM immediately after this
// specific test finishes, keeping the total active count at 1.
t.add_cleanup(() => element.remove());
await new Promise((resolve) => {
element.onvalidationstatuschange = t.step_func(() => {
// Ignore transient initialization states.
if (
element.invalidReason === "unsuccessful_registration" ||
element.invalidReason === "intersection_changed"
) {
return;
}
assert_equals(
element.invalidReason,
expectedInvalidReason,
`display: ${displayValue} should be ${expectedInvalidReason === "" ? "valid" : "invalid"}`
);
resolve();
});
});
// Yield briefly to the event loop so the element.remove() takes effect
// before the next iteration creates a new element.
await new Promise(resolve => step_timeout(resolve, 0));
}, `Geolocation element display style validation: ${displayValue}`);
}
</script>
</body>
</html>