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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/data/websocket/websocket_worker_simple.js
diff --git a/net/data/websocket/websocket_worker_simple.js b/net/data/websocket/websocket_worker_simple.js
new file mode 100644
index 0000000000000000000000000000000000000000..175d51fad15695d423e990fe14cbf2af83cea015
--- /dev/null
+++ b/net/data/websocket/websocket_worker_simple.js
@@ -0,0 +1,33 @@
+if (!self.postMessage) {
+ // This is a shared worker - mimic dedicated worker APIs
+ onconnect = function(event) {
+ event.ports[0].onmessage = function(e) {
+ self.postMessage = function (msg) {
+ event.ports[0].postMessage(msg);
+ };
+ runTests(e.data);
+ };
+ };
+} else {
+ runTests(event.data);
+}
+
+// This test is compatible with shared-worker-simple.html layout test.
+runTests = function (url) {
+ var ws;
+ try {
+ ws = new WebSocket(url);
+ ws.onopen = function() {
+ ws.send("hello");
+ };
+ ws.onmessage = function() {
+ // 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.
+ ws.close();
+ };
+ 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
+ postMessage("DONE");
+ };
+ } catch (e) {
+ postMessage("FAIL: worker: Unexpected exception: " + e);
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698