-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
test.html
41 lines (35 loc) · 984 Bytes
/
test.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>clipboard-copy test</title>
</head>
<body>
<p>
1. Click this button: <button>Copy</button>
</p>
<p>
2. Paste into this input: <input />
</p>
<p>
3. Test status: <strong>pending</strong>
</p>
<script type="text/javascript">
window.module = {}
</script>
<script src="index.js"></script>
<script type="text/javascript">
var secret = Math.random().toFixed(10).slice(2)
function setStatus (success) {
document.querySelector('strong').style.color = (success ? 'green' : 'red')
document.querySelector('strong').textContent = (success ? 'passed' : 'failed')
}
document.querySelector('button').addEventListener('click', function () {
if (!window.module.exports(secret)) setStatus(false)
})
document.querySelector('input').addEventListener('input', function (ev) {
setStatus(ev.target.value === secret)
})
</script>
</body>
</html>