-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
test-worker.html
45 lines (41 loc) · 1.07 KB
/
test-worker.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch Worker Tests</title>
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="/node_modules/url-search-params/build/url-search-params.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>
<script>
if (self.initMochaPhantomJS) {
self.initMochaPhantomJS()
}
mocha.setup('tdd')
mocha.suite.suites.unshift(Mocha.Suite.create(mocha.suite, "worker"))
var worker = new Worker('/test/worker.js')
worker.addEventListener('message', function(e) {
switch (e.data.name) {
case 'pass':
test(e.data.title, function() {})
break
case 'pending':
test(e.data.title)
break
case 'fail':
test(e.data.title, function() {
var err = new Error(e.data.message)
err.stack = e.data.stack
throw err
})
break
case 'end':
mocha.run()
break
}
})
</script>
</body>
</html>