File: selectmenu-popover.tentative.html

package info (click to toggle)
thunderbird 1%3A115.16.0esr-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,476,252 kB
  • sloc: cpp: 6,972,150; javascript: 5,209,211; ansic: 3,507,222; python: 1,137,609; asm: 432,531; xml: 205,149; java: 175,761; sh: 116,485; makefile: 22,152; perl: 13,971; objc: 12,561; yacc: 4,583; pascal: 2,840; lex: 1,720; ruby: 1,075; exp: 762; sql: 666; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (107 lines) | stat: -rw-r--r-- 4,048 bytes parent folder | download | duplicates (4)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<title>HTMLSelectMenuElement Test: popover</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<selectmenu id="selectMenu0">
  <option>one</option>
  <option id="selectMenu0-child2">two</option>
  <div id="selectMenu0-child3">I'm a div with no part attr</div>
  <option>three</option>
  <option>four</option>
</selectmenu>

<selectmenu id="selectMenu1">
  <div slot="button" behavior="button" class="button">
    Custom button
  </div>
  <div popover slot="listbox" behavior="listbox">
    <option>one</option>
    <option class="child2">two</option>
    <option class="child3">three</option>
  </div>
</selectmenu>

<selectmenu id="selectMenu2">
  <!-- Swap out the listbox part without providing a replacement -->
  <div slot="listbox"></div>
</selectmenu>

<selectmenu id="selectMenu3">
  <div slot="listbox">
    <div popover behavior="listbox" id="selectMenu3-listbox">
      <option>one</option>
    </div>
  </div>
</selectmenu>
<script>

  function clickOn(element) {
    const actions = new test_driver.Actions();
    return actions.pointerMove(0, 0, {origin: element})
      .pointerDown({button: actions.ButtonType.LEFT})
      .pointerUp({button: actions.ButtonType.LEFT})
      .send();
  }

  promise_test(async () => {
    const selectMenu0 = document.getElementById("selectMenu0");
    const selectMenu0Child2 = document.getElementById("selectMenu0-child2");
    const selectMenu0Child3 = document.getElementById("selectMenu0-child3");
    assert_equals(selectMenu0.value, "one");
    assert_equals(selectMenu0.open, false);
    await clickOn(selectMenu0);
    assert_equals(selectMenu0.open, true);
    await clickOn(selectMenu0Child2);
    assert_equals(selectMenu0.value, "two");
    assert_equals(selectMenu0.open, false);

    await clickOn(selectMenu0);
    assert_equals(selectMenu0.open, true);
    await clickOn(selectMenu0Child3);
    assert_equals(selectMenu0.value, "two", "Clicking a non-option should not change the value");
    assert_equals(selectMenu0.open, true);
    await clickOn(selectMenu0Child2);
    assert_equals(selectMenu0.open, false);
  }, "Opening the popover and clicking an option should change the selectmenu's value");

  promise_test(async () => {
    const selectMenu1 = document.getElementById("selectMenu1");
    const button = selectMenu1.querySelector(".button");
    const child2 = selectMenu1.querySelector(".child2");
    const child3 = selectMenu1.querySelector(".child3");
    assert_equals(selectMenu1.value, "one");
    assert_equals(selectMenu1.open, false);
    await clickOn(button);
    assert_equals(selectMenu1.open, true);
    await clickOn(child2);
    assert_equals(selectMenu1.value, "two", "Clicking an <option> should change the value");
    assert_equals(selectMenu1.open, false);

    await clickOn(button);
    assert_equals(selectMenu1.open, true);
    await clickOn(child3);
    assert_equals(selectMenu1.value, "three", "Clicking a <div part='option'> should change the value");
    assert_equals(selectMenu1.open, false);
  }, "With custom button and popover: opening the popover and clicking an option should change the selectmenu's value");

  promise_test(async () => {
    const selectMenu2 = document.getElementById("selectMenu2");
    await clickOn(selectMenu2);
    assert_equals(selectMenu2.value, "");
    assert_equals(selectMenu2.open, false);
  }, "Clicking a popover with no listbox part does nothing");

  promise_test(async () => {
    const selectMenu3 = document.getElementById("selectMenu3");
    const selectMenu3Listbox = document.getElementById("selectMenu3-listbox");
    selectMenu3Listbox.remove();

    await clickOn(selectMenu3);
    assert_equals(selectMenu3.value, "");
    assert_equals(selectMenu3.open, false);
  }, "Clicking a popover with a listbox that was removed does nothing");
</script>