9a873721ad744ead96e61f61ecc2d3cbabe588fa
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hybi / unpaired-surrogates-in-message.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("Checks whether SYNTAX_ERR is thrown when attemping to send unpaired surrogates.");
11
12 window.jsTestIsAsync = true;
13 if (window.testRunner)
14     testRunner.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
15
16 var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/echo");
17
18 ws.onopen = function()
19 {
20     debug("Connected.");
21     try {
22         ws.send('\uD807');
23         testFailed('SYNTAX_ERR should be thrown.');
24     } catch(e) {
25         if (e.name == 'SYNTAX_ERR')
26             testPassed('SYNTAX_ERR was thrown.');
27         else
28             testFailed('Unexpected exception: ' + e);
29     }
30     ws.close();
31 };
32
33 ws.onmessage = function (event)
34 {
35     var message = event.data;
36     testFailed("onmessage() was called. (message = \"" + message + "\")");
37     ws.close();
38 };
39
40 ws.onclose = function()
41 {
42     finishJSTest();
43 };
44
45 </script>
46 <script src="../../../../js-test-resources/js-test-post.js"></script>
47 </body>
48 </html>