WebSocket: Receive binary message as ArrayBuffer
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hybi / workers / receive-arraybuffer.html
1 <!DOCTYPE html>
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("WebSocket: Receive ArrayBuffers in Web Workers.");
12
13 window.jsTestIsAsync = true;
14 if (window.layoutTestController)
15     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
16
17 function startsWith(str, prefix)
18 {
19     return str.indexOf(prefix) == 0;
20 }
21
22 var worker = new Worker("resources/receive-arraybuffer.js");
23 worker.onmessage = function (event)
24 {
25     var message = event.data;
26     if (startsWith(message, "PASS"))
27         testPassed(message);
28     else if (startsWith(message, "FAIL"))
29         testFailed(message)
30     else
31         debug(message);
32     if (message === "DONE")
33         finishJSTest();
34 };
35
36 var successfullyParsed = true;
37 </script>
38 <script src="../../../../../js-test-resources/js-test-post.js"></script>
39 </body>
40 </html>