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
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=502258
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 502258</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/WindowSnapshot.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<script>
SimpleTest.waitForExplicitFinish();
async function test_append_char(aId) {
let element = document.getElementById(aId);
element.focus();
let baseSnapshot = await snapshotWindow(window);
element.selectionStart = element.selectionEnd = element.value.length;
await new Promise(resolve => setTimeout(resolve, 0));
sendString('f');
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
let selectionAtTheEndSnapshot = await snapshotWindow(window);
assertSnapshots(baseSnapshot, selectionAtTheEndSnapshot, /* equal = */ false, /* fuzz = */ null, "baseSnapshot", "selectionAtTheEndSnapshot");
// Re-setting value shouldn't change anything.
// eslint-disable-next-line no-self-assign
element.value = element.value;
let tmpSnapshot = await snapshotWindow(window);
assertSnapshots(baseSnapshot, tmpSnapshot, /* equal = */ false, /* fuzz = */ null, "baseSnapshot", "tmpSnapshot");
assertSnapshots(selectionAtTheEndSnapshot, tmpSnapshot, /* equal = */ true, /* fuzz = */ null, "selectionAtTheEndSnapshot", "tmpSnapshot");
element.selectionStart = element.selectionEnd = 0;
element.blur();
}
async function runTest() {
await SpecialPowers.pushPrefEnv({set: [["layout.forms.reveal-password-button.enabled", true]]});
document.getElementById("content").style.display = "";
document.getElementById("content").getBoundingClientRect();
await test_append_char('test1');
await test_append_char('test2');
await test_append_char('test3');
await test_append_char('test4');
SimpleTest.finish();
}
SimpleTest.waitForFocus(runTest);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=502258">Mozilla Bug 502258</a>
<p id="display"></p>
<style>input {appearance:none}</style>
<div id="content" style="display: none">
<input id="test1" type=password>
<input id="test2" type=password value="123">
<!-- text value masked off -->
<div style="position:relative; margin: 1em 0;">
<input id="test3" type=password style="position:absolute">
<div style="position:absolute; top:0;left:0; width:10ch; height:2em; background:black"></div>
</div>
<br>
<!-- Show Password button masked off -->
<div style="position:relative; margin: 1em 0;">
<input id="test4" type=password style="position:absolute">
<div style="position:absolute; top:0;left:10ch; width:20ch; height:2em; background:black"></div>
</div>
</div>
<pre id="test">
</pre>
</body>
</html>
|