blob: b9a9f170e8ca3f464efdffe4a44e3a5765f59131 (
plain)
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
|
<!DOCTYPE html>
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function buildInlineSharedWorker() {
var script = document.getElementById('workerCode').innerText;
var blob = new Blob([script], {type: 'text/javascript'});
var worker = new SharedWorker(URL.createObjectURL(blob));
worker.port.start();
worker.port.postMessage({cmd: 'connect', id: "host"});
worker.port.addEventListener('message', function (e) {
if (e.data.done)
setTimeout(finishJSTest, 0);
});
return worker;
}
</script>
</head>
<body>
<!-- This script's body will be used to build a Blob URL to use as a Worker. -->
<script id="workerCode" type="text/plain">
console.log("log");
console.log(typeof console.log);
console.log(console.log.toString());
console.error("error");
console.warn("warn");
console.info("info");
console.debug("debug");
/*
// FIXME(slightlyoff): these aren't getting logged properly from here!
console.assert(true);
console.assert(false);
console.markTimeline("markTimeline");
*/
self.addEventListener("connect", function (e) {
var port = e.ports[0];
port.postMessage({ done: true });
});
</script>
<script>
window.jsTestIsAsync = true;
description("This tests that 'console.log' and friends function correctly from workers.");
buildInlineSharedWorker();
</script>
</body>
</html>
|