summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/test/test_bug_787624.html
blob: 6ca5136cd8ac510b69799f762bee0dc182a68b75 (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
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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Layout of Form History Autocomplete: Bug 787624</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
  <script type="text/javascript" src="satchel_common.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <style>
    .container {
        border: 1px solid #333;
        width: 80px;
        height: 26px;
        position: absolute;
        z-index: 2;
    }

    .subcontainer {
        width: 100%;
        overflow: hidden;
    }

    .subcontainer input {
        width: 120px;
        margin: 2px 6px;
        padding-right: 4px;
        border: none;
        height: 22px;
        z-index: 1;
        outline: 1px dashed #555
    }
  </style>
</head>
<body>
Form History Layout test: form field autocomplete: Bug 787624
<p id="display"></p>

<!-- we presumably can't hide the content for this test. -->
<div id="content">
  <!-- in this form, the input field is partially hidden and can scroll -->
  <div class="container">
    <div class="subcontainer">
      <form id="form1" onsubmit="return false;">
        <input  type="text" name="field1">
        <button type="submit">Submit</button>
      </form>
    </div>
  </div>
</div>

<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Form History autocomplete Layout: Bug 787624 **/

var resolvePopupShownListener;
registerPopupShownListener(() => resolvePopupShownListener());

function waitForNextPopup() {
  return new Promise(resolve => { resolvePopupShownListener = resolve; });
}

add_task(function* test_popup_not_move_input() {
  var input = $_(1, "field1");
  var rect = input.getBoundingClientRect();

  yield new Promise(resolve => updateFormHistory([
    { op : "remove" },
    { op : "add", fieldname : "field1", value : "value1" },
    { op : "add", fieldname : "field1", value : "value2" },
  ], resolve));

  let popupShown = waitForNextPopup();
  input.focus();
  doKey("down");
  yield popupShown;

  var newRect = input.getBoundingClientRect();
  is(newRect.left, rect.left,
    "autocomplete popup does not disturb the input position");
  is(newRect.top, rect.top,
    "autocomplete popup does not disturb the input position");
});

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