2011-07-06 Adam Barth <abarth@webkit.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / frame-length-longer-than-buffer.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("Make sure WebSocket correctly skip lengthed frame even if received data has incomplete frame.");
12
13 window.jsTestIsAsync = true;
14
15 var received_messages = [];
16 var expected_messages = ["hello"];
17 function finish() {
18     clearTimeout(timeoutID);
19     debug(received_messages.length);
20     for (var i = 0; i < received_messages; i++) {
21         debug("received[" + i + "]=" + received_messages[i]);
22     }
23
24     shouldBeTrue("areArraysEqual(received_messages, expected_messages)");
25
26     finishJSTest();
27 }
28
29 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/frame-length-longer-than-buffer");
30 ws.onopen = function () {
31     debug("WebSocket is open");
32 };
33 ws.onmessage = function (evt) {
34     debug("received:" + evt.data);
35     received_messages.push(evt.data);
36 };
37 ws.onclose = function () {
38     debug("WebSocket is closed");
39     finish();
40 };
41 var timeoutID = setTimeout("finish()", 2000);
42
43 var successfullyParsed = true;
44 </script>
45 <script src="../../../../js-test-resources/js-test-post.js"></script>
46 </body>
47 </html>