Skip to content

Commit

Permalink
Bug 1769966 [wpt PR 34107] - Clean up modal dialog tests and split ou…
Browse files Browse the repository at this point in the history
…t :modal pseudo-class test, a=testonly

Automatic update from web-platform-tests
Clean up modal dialog tests and split out :modal pseudo-class test (#34107)

Closes web-platform-tests/interop#79

--

wpt-commits: f4e735e4245973ad955ecadab644b71a3d4533df
wpt-pr: 34107
  • Loading branch information
nt1m authored and moz-wptsync-bot committed May 24, 2022
1 parent 9691cc1 commit 18dd749
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 38 deletions.
38 changes: 38 additions & 0 deletions testing/web-platform/tests/css/selectors/modal-pseudo-class.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<meta charset="utf-8"/>
<title>:modal pseudo-class</title>
<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m">
<link rel="help" href="https://drafts.csswg.org/selectors/#modal-state">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<dialog id="dialog">Just another dialog.</dialog>

<script>
setup({ single_test: true });

const dialog = document.getElementById("dialog");
assert_false(dialog.matches(":modal"), "dialog is initially closed (does not match :modal)");

dialog.showModal();
assert_true(dialog.matches(":modal"), "dialog should match :modal after showModal() call");

dialog.close();
assert_false(dialog.matches(":modal"), "dialog should no longer match :modal after close() call");

dialog.show();
assert_false(dialog.matches(":modal"), "dialog shouldn't match :modal after show() call");

dialog.close();
dialog.showModal();
assert_true(dialog.matches(":modal"), "dialog should match :modal after showModal() call");

dialog.remove();
assert_false(dialog.matches(":modal"), "dialog shouldn't match :modal after being removed from document");
document.body.append(dialog);
assert_false(dialog.matches(":modal"), "dialog shouldn't match :modal after being re-appended to document");

dialog.close();

done();
</script>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@
test(function(){
assert_false(d1.open);
assert_false(d1.hasAttribute("open"));
assert_equals(getComputedStyle(d1).display, "none");
d1.showModal();
this.add_cleanup(function() { d1.close(); });
assert_true(d1.open);
assert_equals(d1.getAttribute("open"), "");
assert_equals(getComputedStyle(d1).display, "block");
assert_equals(document.activeElement, b1);
});

Expand Down Expand Up @@ -169,4 +171,18 @@
d11.close();
assert_equals(topElement(), d10);
}, "when opening multiple dialogs, the most recently opened is rendered on top");

test(function() {
assert_false(d11.open);
d11.parentNode.removeChild(d11);
assert_throws_dom("INVALID_STATE_ERR", () => d11.showModal());

const doc = document.implementation.createHTMLDocument();
doc.body.appendChild(d11);
this.add_cleanup(() => document.body.append(d11));
assert_false(d11.open);
d11.showModal();
assert_true(d11.open);
this.add_cleanup(() => d11.close());
}, "Although the document is not attached to any pages, showModal() should execute as normal.");
</script>

0 comments on commit 18dd749

Please sign in to comment.