summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html
blob: aff976d1ad5c704e4ece24fe524244b119bee106 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1422275">
<link rel=help href="https://github.com/openui/open-ui/issues/433#issuecomment-1452461404">
<link rel=help href="https://github.com/openui/open-ui/issues/386#issuecomment-1452469497">
<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>
<script src="/resources/testdriver-actions.js"></script>

<style>
select {
  appearance: base-select;
}
</style>

<!-- TODO(http://crbug.com/1511354): Add test cases with no <button> and no <datalist>. -->
<select>
  <button type=popover>button</button>
  <datalist>
    <option class=one>one</option>
    <option class=two>two</option>
  </datalist>
</select>

<script>
const select = document.querySelector('select');
const button = document.querySelector('button');
const optionOne = document.querySelector('option.one');
const optionTwo = document.querySelector('option.two');

promise_test(async () => {
  assert_false(select.matches(':open'),
    'Select should be closed at the start of the test.');

  await test_driver.click(button);
  assert_true(select.matches(':open'),
    'Select should be open after clicking the button.');

  await test_driver.click(button);
  assert_false(select.matches(':open'),
    'Select should be closed after clicking the button a second time.');
}, 'Select with appearance:base-select should open and close when clicking the button.');

promise_test(async () => {
  assert_false(select.matches(':open'),
    'Select should be closed at the start of the test.');
  assert_equals(select.value, 'one',
    'Select.value should be one at the start of the test.');

  await test_driver.click(button);
  assert_true(select.matches(':open'),
    'Select should be open after clicking the button.');

  await test_driver.click(optionTwo);
  assert_false(select.matches(':open'),
    'Select should be closed after clicking an option.');
  assert_equals(select.value, 'two',
    'Select.value should be two after clicking the option.');
}, 'Clicking an option in an appearance:base-select select should choose the option and close the popover.');
</script>