Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/interactive-elements/the-dialog-element/dialog-cancel-with-select.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<title>Test dialog modal is closed by escape key with select focused</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
</head>
<body>
<p>Test dialog modal is closed by escape key with select focused</p>
<dialog id="dialog">
<select>
<option value="one">one</option>
<option value="two">two</option>
</select>
</dialog>
<script>
setup({ single_test: true });
const dialog = document.getElementById("dialog");
const select = document.querySelector("select");
dialog.addEventListener("close", function() {
assert_false(dialog.open, "dialog with select is closed");
done();
});
dialog.showModal();
assert_true(select == document.activeElement, "select element should be focused");
test_driver.send_keys(document.documentElement, "\uE00C"); // ESC key
</script>
</body>
</html>