2011-07-05 Yuta Kitamura <yutak@chromium.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / null-character.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 transfer null character");
12
13 window.jsTestIsAsync = true;
14
15 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/echo");
16 // \xff in string would be \xc3\xbf on websocket connection (UTF-8)
17 var expectedMessage = "Should Not\xff\0Split";
18
19 ws.onopen = function()
20 {
21     debug("WebSocket open");
22     ws.send(expectedMessage);
23 };
24
25 var msg;
26 ws.onmessage = function(messageEvent)
27 {
28     msg = messageEvent.data;
29     debug("msg should not be split by frame char \\xff\\0");
30     shouldBe("msg", "expectedMessage");
31     ws.close();
32 };
33
34 ws.onclose = function()
35 {
36     debug("WebSocket closed");
37     finishJSTest();
38 };
39
40 var successfullyParsed = true;
41 </script>
42 <script src="../../../../js-test-resources/js-test-post.js"></script>
43 </body>
44 </html>