Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 if (!self.postMessage) { | |
| 2 // This is a shared worker - mimic dedicated worker APIs | |
| 3 onconnect = function(event) { | |
| 4 event.ports[0].onmessage = function(e) { | |
| 5 self.postMessage = function (msg) { | |
| 6 event.ports[0].postMessage(msg); | |
| 7 }; | |
| 8 runTests(e.data); | |
| 9 }; | |
| 10 }; | |
| 11 } else { | |
| 12 runTests(event.data); | |
| 13 } | |
| 14 | |
| 15 // This test is compatible with shared-worker-simple.html layout test. | |
| 16 runTests = function (url) { | |
| 17 var ws; | |
| 18 try { | |
| 19 ws = new WebSocket(url); | |
| 20 ws.onopen = function() { | |
| 21 ws.send("hello"); | |
| 22 }; | |
| 23 ws.onmessage = function() { | |
| 24 // Receive echoed "hello". | |
|
Yuta Kitamura
2012/10/15 07:44:37
Don't you check the received message?
Takashi Toyoshima
2012/10/15 08:14:34
Done.
| |
| 25 ws.close(); | |
| 26 }; | |
| 27 ws.onclose = function(e) { | |
|
Yuta Kitamura
2012/10/15 07:44:37
Also it's nice to check |e| if possible.
Takashi Toyoshima
2012/10/15 08:14:34
I'll check e.wasClean here.
If you think we shoul
| |
| 28 postMessage("DONE"); | |
| 29 }; | |
| 30 } catch (e) { | |
| 31 postMessage("FAIL: worker: Unexpected exception: " + e); | |
| 32 } | |
| 33 }; | |
| OLD | NEW |