|
5 | 5 | <script src="/resources/testharnessreport.js"></script>
|
6 | 6 | <script src="/resources/testdriver.js"></script>
|
7 | 7 | <script src="/resources/testdriver-vendor.js"></script>
|
8 |
| -<body></body> |
| 8 | + |
| 9 | +<body> |
9 | 10 | <script type=module>
|
10 | 11 | import inputTypes from "./input-types.js";
|
11 | 12 |
|
12 |
| -for (const inputType of inputTypes) { |
13 |
| - test(() => { |
14 |
| - const input = document.createElement("input"); |
15 |
| - input.setAttribute("type", inputType); |
| 13 | +// File pickers can't be closed. |
| 14 | +const types = inputTypes.filter((t) => t != 'file'); |
16 | 15 |
|
| 16 | +function createElement(t,type) { |
| 17 | + const input = document.createElement("input"); |
| 18 | + input.setAttribute("type", type); |
| 19 | + document.body.appendChild(input); |
| 20 | + t.add_cleanup(() => input.remove()); |
| 21 | + return input; |
| 22 | +} |
| 23 | +for (const inputType of types) { |
| 24 | + promise_test(async (t) => { |
| 25 | + const input = createElement(t,inputType); |
17 | 26 | assert_throws_dom('NotAllowedError', () => { input.showPicker(); });
|
18 | 27 | }, `input[type=${inputType}] showPicker() requires a user gesture`);
|
19 |
| -} |
20 |
| - |
21 |
| -for (const inputType of inputTypes) { |
22 |
| - promise_test(async t => { |
23 |
| - const input = document.createElement("input"); |
24 |
| - input.setAttribute("type", inputType); |
25 | 28 |
|
| 29 | + promise_test(async (t) => { |
| 30 | + const input = createElement(t,inputType); |
26 | 31 | await test_driver.bless('show picker');
|
27 | 32 | input.showPicker();
|
28 | 33 | input.blur();
|
29 | 34 | }, `input[type=${inputType}] showPicker() does not throw when user activation is active`);
|
30 |
| -} |
31 |
| - |
32 |
| -for (const inputType of inputTypes) { |
33 |
| - promise_test(async () => { |
34 |
| - const input = document.createElement('input'); |
35 |
| - input.setAttribute('type', inputType); |
36 | 35 |
|
| 36 | + promise_test(async (t) => { |
| 37 | + const input = createElement(t,inputType); |
37 | 38 | await test_driver.bless('show picker');
|
38 | 39 | input.showPicker();
|
39 | 40 | input.blur();
|
40 |
| - |
41 | 41 | assert_false(navigator.userActivation.isActive);
|
42 | 42 | }, `input[type=${inputType}] showPicker() consumes user activation`);
|
43 | 43 | }
|
|
0 commit comments