Debian Codegraph @

testing/web-platform/mozilla/tests/dom/dispatch_select_event.html

raw
1 <!-- See also Bug 1679427.
2 Ensure `select` event is only fired once when tab-ing to an `<input>` element.
3 -->
4 <!doctype html>
5 <html>
6 <head>
7 <script src=/resources/testharness.js></script>
8 <script src=/resources/testharnessreport.js></script>
9 <script src="/resources/testdriver.js"></script>
10 <script src="/resources/testdriver-vendor.js"></script>
11 </head>
12 <body>
13 <button>Press this button and Press Tab</button><input value="abc">
14 <script>
15 promise_test(async t => {
16 await new Promise(resolve => { window.onload = resolve; });
17 const button = document.querySelector("button");
18 const input = document.querySelector("input");
19
20 let countSelectEvent = 0;
21 input.addEventListener("select", event => {
22 countSelectEvent++;
23 });
24
25 button.focus();
26 const tabKey = "\uE004";
27 await test_driver.send_keys(button, tabKey);
28 await new Promise(resolve => requestAnimationFrame(
29 () => requestAnimationFrame(resolve)
30 ));
31 assert_equals(countSelectEvent, 1, "Select event was fired more than once!");
32 }, "Select event should only be fired once.");
33 </script>
34 </body>
35 </html>