7e218ef685349fd9d5084832589559bb2e9a1d11
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / send-throw.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
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 type="text/javascript">
10 description("Web Socket send test");
11
12 window.jsTestIsAsync = true;
13 if (window.testRunner)
14     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
15
16 function endTest()
17 {
18     clearTimeout(timeoutID);
19     finishJSTest();
20 }
21
22 var ws = new WebSocket("ws://localhost:8880/websocket/tests/hixie76/send");
23
24 var FIRST_MESSAGE_TO_SEND = {
25     toString: function() { throw "Pickles"; }
26 };
27 // data needs to be global to be accessbile from shouldBe().
28 var data = "";
29
30 ws.onopen = function()
31 {
32     debug("Connected.");
33     try {
34         ws.send(FIRST_MESSAGE_TO_SEND);
35     } catch (ex) {
36         debug("Caught exception: " + ex);
37     }
38     ws.close();
39 };
40
41 ws.onclose = function()
42 {
43     debug("Closed.");
44     endTest();
45 };
46
47 function timeOutCallback()
48 {
49     testFailed("Timed out in state: " + ws.readyState);
50     endTest();
51 }
52
53 var timeoutID = setTimeout(timeOutCallback, 3000);
54
55 </script>
56 <script src="../../../../js-test-resources/js-test-post.js"></script>
57 </body>
58 </html>