summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-cancel-with-select.html
blob: 178d5a27114bba6179792322546c152d4d524101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!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>
  <link rel="help" href="https://bugs.webkit.org/show_bug.cgi?id=227534">
  <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">
</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>