File: test_autocorrect.html

package info (click to toggle)
firefox 146.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,653,260 kB
  • sloc: cpp: 7,587,892; javascript: 6,509,455; ansic: 3,755,295; python: 1,410,813; xml: 629,201; asm: 438,677; java: 186,096; sh: 62,697; makefile: 18,086; objc: 13,087; perl: 12,811; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (66 lines) | stat: -rw-r--r-- 2,790 bytes parent folder | download | duplicates (13)
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
<!DOCTYPE html>
<html>
<head>
  <title>Tests for autocorrect</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/SpecialPowers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>

<div>
<input type="text" id="a1"><br>
<input type="text" id="a2" autocorrect="on"><br>
<input type="text" id="a3" autocorrect="off"><br>
<input type="url" id="a4" autocorrect="on"><br>
<input type="email" id="a5" autocorrect="on"><br>
<input type="password" id="a6" autocorrect="on"><br>
<textarea id="b1"></textarea><br>
<textarea id="b2" autocorrect="on"></textarea><br>
<textarea id="b3" autocorrect="off"></textarea><br>
<div contenteditable id="c1"></div><br>
<div contenteditable id="c2" autocorrect="on"></div><br>
<div contenteditable id="c3" autocorrect="off"></div><br>
<form><input type="text" id="d1" autocorrect="on"></form><br>
<form autocorrect="on"><input type="text" id="d2"></form><br>
<form autocorrect="off"><input type="text" id="d3" autocorrect="on"></form><br>
</div>

<pre id="test">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();

SimpleTest.waitForFocus(async () => {
  await SpecialPowers.setBoolPref("dom.forms.autocorrect", true);

  const tests = [
    { id: "a1", autocorrect: true, desc: "input without autocorrect" },
    { id: "a2", autocorrect: true, desc: "input with autocorrect=on" },
    { id: "a3", autocorrect: false, desc: "input with autocorrect=off" },
    { id: "a4", autocorrect: false, desc: "input type=url with autocorrect=on" },
    { id: "a5", autocorrect: false, desc: "input type=email with autocorrect=on" },
    { id: "a6", autocorrect: false, desc: "input type=password with autocorrect=on" },
    { id: "b1", autocorrect: true, desc: "textarea without autocorrect" },
    { id: "b2", autocorrect: true, desc: "textarea with autocorrect=on" },
    { id: "b3", autocorrect: false, desc: "textarea with autocorrect=off" },
    { id: "c1", autocorrect: true, desc: "contenteditable without autocorrect" },
    { id: "c2", autocorrect: true, desc: "contenteditable with autocorrect=on" },
    { id: "c3", autocorrect: false, desc: "contenteditable with autocorrect=off" },
    { id: "d1", autocorrect: true, desc: "input with autocorrect=on in form" },
    { id: "d2", autocorrect: true, desc: "input in form with autocorrect=on" },
    { id: "d3", autocorrect: true, desc: "input with autocorrect=on in form" },
  ];

  for (let test of tests) {
    document.getElementById(test.id).focus();
    is(SpecialPowers.DOMWindowUtils.focusedAutocorrect, test.autocorrect, test.desc);
  }

  SimpleTest.finish();
});
</script>
</pre>
</body>
</html>