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
|
<!DOCTYPE html>
<html>
<!--
bugzilla.mozilla.org/show_bug.cgi?id=1673434
-->
<head>
<title>Test for bug 1673434</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1673434">Mozilla Bug 1673434</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<input type="checkbox">
<input type="radio" name="group" value="foo">
<input type="radio" name="group" value="bar" checked>
<input type="text">
<script>
const utils = SpecialPowers.DOMWindowUtils;
function test_events(element, resolve) {
element.addEventListener("input", () => {
is(utils.isHandlingUserInput, false,
"isHandlingUserInput is false on input event by element.click()");
}, { once: true });
element.addEventListener("change", () => {
is(utils.isHandlingUserInput, false,
"isHandlingUserInput is false on change event by element.click()");
resolve();
}, { once: true });
element.click();
}
add_task(function testCheckboxEvent() {
return new Promise(resolve => {
let element = document.querySelector("input[type=checkbox]");
test_events(element, resolve);
});
});
add_task(function testRadioEvent() {
return new Promise(resolve => {
let element = document.querySelector("input[type=radio]");
test_events(element, resolve);
});
});
add_task(function testUserInput() {
// setUserInput should be handled as user input.
//
// XXX <textarea> won't fire input event by setUserInput.
return new Promise(resolve => {
let element = document.querySelector("input[type=text]");
element.addEventListener("input", () => {
is(utils.isHandlingUserInput, true,
"isHandlingUserInput is true on input event by setUserInput");
}, { once: true });
element.addEventListener("change", () => {
is(utils.isHandlingUserInput, true,
"isHandlingUserInput is true on change event by setUserInput");
resolve();
}, { once: true });
SpecialPowers.wrap(element).setUserInput("a");
});
});
</script>
</pre>
</body>
</html>
|