Threadsafety issues in WebScriptObject
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / workers / resources / close-in-worker.js
1 if (self.postMessage)
2     runTests();
3 else
4     onconnect = handleConnect;
5
6 function handleConnect(event)
7 {
8     // For shared workers, create a faux postMessage() API to send message back to the parent page.
9     self.postMessage = function (message) { event.ports[0].postMessage(message); };
10     runTests();
11 };
12
13 function runTests()
14 {
15     var ws;
16     try {
17         postMessage("PASS: worker: init");
18         if ('WebSocket' in self)
19             postMessage("PASS: worker: WebSocket exists");
20         else
21             postMessage("FAIL: worker: no WebSocket");
22         ws = new WebSocket('ws://localhost:8880/websocket/tests/hixie76/workers/resources/echo');
23         ws.onopen = function() {
24             postMessage("PASS: worker: Connected.");
25             ws.close();
26         };
27         ws.onclose = function() {
28             postMessage("PASS: worker: Closed.");
29             postMessage("DONE");
30         };
31     } catch (e) {
32         postMessage("FAIL: worker: Unexpected exception: " + e);
33     } finally {
34         postMessage("PASS: worker: successfullyParsed:" + ws);
35     }
36 };