зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1768514 [wpt PR 33999] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=240109, a=testonly
Automatic update from web-platform-tests WebKit export of https://bugs.webkit.org/show_bug.cgi?id=240109 (#33999) Add tests for `:modal` pseudo class -- wpt-commits: d81f04acd4371d2939c7a30a090c9af913165874 wpt-pr: 33999
This commit is contained in:
Родитель
c07589008f
Коммит
6dc704a6c4
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>CSS Selectors Invalidation: :modal pseudo class in :has()</title>
|
||||
<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m">
|
||||
<link rel="help" href="https://drafts.csswg.org/selectors/#relational">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
#subject:has(#dialog:modal) { color: green }
|
||||
</style>
|
||||
<div id="subject">
|
||||
This is some text.
|
||||
<dialog id="dialog">This is a dialog</dialog>
|
||||
</div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
|
||||
"ancestor should be black since dialog is not modal");
|
||||
dialog.show();
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
|
||||
"ancestor should be black since dialog is not modal");
|
||||
dialog.close();
|
||||
}, ":modal pseudo-class is not active with dialog.show()");
|
||||
test(function() {
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
|
||||
"ancestor should be black");
|
||||
dialog.showModal();
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 128, 0)",
|
||||
"ancestor should be green since dialog is shown modally");
|
||||
dialog.close();
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
|
||||
"ancestor should be black since dialog is closed");
|
||||
}, ":modal pseudo-class invalidation with showModal+close");
|
||||
test(function() {
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
|
||||
"ancestor should be black");
|
||||
dialog.showModal();
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 128, 0)",
|
||||
"ancestor should be green since dialog is shown modally");
|
||||
dialog.remove();
|
||||
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
|
||||
"ancestor should be black since dialog is closed");
|
||||
}, ":modal pseudo-class invalidation with showModal+remove");
|
||||
</script>
|
|
@ -10,26 +10,29 @@
|
|||
|
||||
<script>
|
||||
test(() => {
|
||||
const dialog = document.getElementById('mydialog');
|
||||
const dialog = document.getElementById("mydialog");
|
||||
const computedStyle = window.getComputedStyle(dialog, null);
|
||||
assert_equals(computedStyle.display, 'none');
|
||||
assert_equals(computedStyle.display, "none");
|
||||
assert_false(dialog.matches(":modal"));
|
||||
|
||||
dialog.showModal();
|
||||
assert_equals(computedStyle.display, 'block');
|
||||
assert_equals(computedStyle.display, "block");
|
||||
assert_true(dialog.matches(":modal"));
|
||||
|
||||
// The quoted texts output below are from <http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#dom-dialog-showmodal>.
|
||||
assert_throws_dom('InvalidStateError', () => dialog.showModal());
|
||||
assert_throws_dom("InvalidStateError", () => dialog.showModal());
|
||||
|
||||
dialog.close();
|
||||
assert_equals(computedStyle.display, 'none');
|
||||
assert_equals(computedStyle.display, "none");
|
||||
assert_false(dialog.matches(":modal"));
|
||||
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
assert_throws_dom('InvalidStateError', () => dialog.showModal());
|
||||
assert_throws_dom("InvalidStateError", () => dialog.showModal());
|
||||
|
||||
const doc = document.implementation.createHTMLDocument();
|
||||
doc.body.appendChild(dialog);
|
||||
assert_false(dialog.open);
|
||||
dialog.showModal();
|
||||
assert_true(dialog.open, 'Although the document is not attached to any pages, showModal() should execute as normal.');
|
||||
}, 'Tests that showModal() performs the steps specified in the HTML spec.');
|
||||
assert_true(dialog.open, "Although the document is not attached to any pages, showModal() should execute as normal.");
|
||||
}, "Tests that showModal() performs the steps specified in the HTML spec.");
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче