Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Side by Side Diff: net/data/websocket/websocket_worker_simple.js

Issue 11028111: Replace WorkerWebSocketHttpLayoutTest with WorkerTest.WebSocketSharedWorker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retain std::string reference for GURL::Replacements Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698