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