2011-07-05 Yuta Kitamura <yutak@chromium.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / unicode.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 unicode message 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/hixie76/unicode");
22
23 // Hello in Japanese
24 var UNICODE_HELLO = "\u3053\u3093\u306b\u3061\u306f";
25 // Goodbye in Japanese
26 var UNICODE_GOODBYE = "\u3055\u3088\u3046\u306a\u3089";
27
28 // data needs to be global to be accessbile from shouldBe().
29 var data = "";
30
31 ws.onopen = function()
32 {
33     debug("Connected.");
34     debug("Send UNICODE_HELLO.");
35     ws.send(UNICODE_HELLO);
36 };
37
38 ws.onmessage = function(messageEvent)
39 {
40     // The server should send back Goodbye if it receives Hello.
41     data = messageEvent.data;
42     shouldBe("data", "UNICODE_GOODBYE");
43 };
44
45 ws.onclose = function()
46 {
47     debug("Closed.");
48     endTest();
49 };
50
51 function timeOutCallback()
52 {
53     testFailed("Timed out in state: " + ws.readyState);
54     endTest();
55 }
56
57 var timeoutID = setTimeout(timeOutCallback, 3000);
58
59 var successfullyParsed = true;
60 </script>
61 <script src="../../../../js-test-resources/js-test-post.js"></script>
62 </body>
63 </html>