forked from cypress-io/cypress-test-tiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (46 loc) · 1.25 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Testcase</title>
<meta charset="UTF-8" />
</head>
<body>
<button id="reset">reset</button>
<button id="target">click me then press enter</button>
<div id="log"></div>
<script>
const target = document.getElementById("target");
const reset = document.getElementById("reset");
let log = [];
reset.addEventListener("click", () => {
log = [];
updateLog();
});
const updateLog = (msg) => {
if (msg) {
log.push(msg);
}
const ol = document.createElement("ol");
log.forEach((text) => {
const node = document.createTextNode(text);
const li = document.createElement("li");
li.appendChild(node);
ol.appendChild(li);
});
document.getElementById("log").replaceChildren(ol);
};
target.addEventListener("keydown", () => {
updateLog("keydown");
});
target.addEventListener("keypress", () => {
updateLog("keypress");
});
target.addEventListener("click", () => {
updateLog("click");
});
target.addEventListener("keyup", () => {
updateLog("keyup");
});
</script>
</body>
</html>