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
|
"use strict";
Cu.importGlobalProperties(["URLSearchParams"]);
const HTML_DATA = `
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1222285</title>
<script type="application/javascript">
function populateKeyEventResult(aEvent) {
let result = document.getElementById("result-" + aEvent.type);
let data = {
key: aEvent.key,
code: aEvent.code,
location: aEvent.location,
altKey: aEvent.altKey,
shiftKey: aEvent.shiftKey,
ctrlKey: aEvent.ctrlKey,
charCode: aEvent.charCode,
keyCode: aEvent.keyCode,
modifierState: {
Alt: aEvent.getModifierState("Alt"),
AltGraph: aEvent.getModifierState("AltGraph"),
Shift: aEvent.getModifierState("Shift"),
Control: aEvent.getModifierState("Control")
}
};
result.value = JSON.stringify(data);
result.dispatchEvent(new CustomEvent("resultAvailable"));
}
window.onload = () => {
for (event of ["keydown", "keypress", "keyup"]) {
document.getElementById("test")
.addEventListener(event, populateKeyEventResult);
}
}
</script>
</head>
<body>
<input id="test"/>
<input id="result-keydown"/>
<input id="result-keypress"/>
<input id="result-keyup"/>
</body>
</html>`;
function handleRequest(request, response) {
response.setHeader("Cache-Control", "no-cache", false);
response.setHeader("Content-Type", "text/html", false);
let queryString = new URLSearchParams(request.queryString);
let language = queryString.get("language");
if (language) {
response.setHeader("Content-Language", language, false);
}
response.write(HTML_DATA);
}
|