summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/test/test_datalist_attribute_change.html
blob: f9c774f8d0f73db7c425b2c4b769a5fcd9fadbb4 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Form History / Attribute change with datalist entries: Bug 1767250</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript" src="satchel_common.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="content">

  <form>
    <input list="suggest" type="button" name="input" id="input" />
    <datalist id="suggest">
      <option value="Mozilla">
      <option value="Firefox">
      <option value="Thunderbird">
    </datalist>
  </form>

</div>

<script>

add_task(async function test_dropdown_shown_when_type_attribute_changed() {
  const input = document.getElementById("input");
  input.addEventListener("click", () => input.setAttribute("type", "text"));

  is(input.type, "button", "Input type is initially button.");

  synthesizeMouseAtCenter(input, { button: input, type: "mousedown" }, window);
  synthesizeMouseAtCenter(input, { button: input, type: "mouseup" }, window);

  await SimpleTest.promiseWaitForCondition(() => input.type === "text", "Input type changed to text.");

  is(document.activeElement, input, "Text input is focused.");
  // In the course of fixing Bug 1767250, we discovered that the focus ring was not shown although the element was focused.
  // We decided to refer fixing this to a later bug,  This is tracked in Bug 1788698.
  // ok(input.matches(":focus-visible"), "Outer focus ring is shown.");

  await openPopupOn(input);

  isDeeply(
    getMenuEntries(),
    ["Mozilla", "Firefox", "Thunderbird"],
    "Datalist shown after changing input type from button to text.");
  input.removeEventListener("click", () => input.setAttribute("type", "text"));
});

</script>
</body>
</html>