Threadsafety issues in WebScriptObject
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / send-object.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../../js-test-resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
9 <script>
10 description("WebSocket: send(object) should be interpreted as send(object.toString()).");
11
12 window.jsTestIsAsync = true;
13 if (window.testRunner)
14     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
15
16 function createEmptyBlob()
17 {
18     return new Blob([]);
19 }
20
21 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/echo");
22
23 var closeEvent;
24 var receivedMessages = [];
25 var expectedMessages = ["[object Object]", "[object ArrayBuffer]", "[object Blob]", "Goodbye"];
26
27 ws.onopen = function()
28 {
29     ws.send({});
30     ws.send(new ArrayBuffer());
31     ws.send(createEmptyBlob());
32     ws.send("Goodbye");
33 };
34
35 ws.onmessage = function(event)
36 {
37     receivedMessages.push(event.data);
38 };
39
40 ws.onclose = function(event)
41 {
42     closeEvent = event;
43     shouldBeTrue("closeEvent.wasClean");
44
45     shouldEvaluateTo("receivedMessages.length", expectedMessages.length);
46     for (var i = 0; i < expectedMessages.length; ++i)
47         shouldBeEqualToString("receivedMessages[" + i + "]", expectedMessages[i]);
48     finishJSTest();
49 };
50
51 </script>
52 <script src="../../../../js-test-resources/js-test-post.js"></script>
53 </body>
54 </html>