4 <meta http-equiv=
"Content-Type" content=
"text/html;charset=UTF-8"></meta>
5 <title>WebSocket test - big blob on content side
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <script type=
"text/javascript" src=
"websocket_helpers.js"></script>
8 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
11 <script class=
"testbody" type=
"text/javascript">
13 var ws = CreateTestWS(
"ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_bigBlob");
14 is(ws.readyState,
0,
"Initial readyState is 0");
15 ws.binaryType =
"blob";
17 ws.onopen = function() {
18 is(ws.readyState,
1,
"Open readyState is 1");
19 ws.send(new Blob([new Array(
1024*
1024).join('
123456789ABCDEF')]));
23 ws.onmessage = function(e) {
24 ok(e.data instanceof Blob,
"We should be receiving a Blob");
25 receivedBlob = e.data;
29 ws.onclose = function(e) {
30 is(ws.readyState,
3,
"Close readyState is 3");
32 // check blob contents
33 var reader = new FileReader();
34 reader.onload = function(event) {
35 is(reader.result, new Array(
1024*
1024).join('
123456789ABCDEF'),
"All data matches");
38 reader.onerror = function(event) {
39 ok(false,
"Something bad happen.");
42 reader.onloadend = function(event) {
46 reader.readAsBinaryString(receivedBlob);
49 SimpleTest.requestFlakyTimeout(
"The web socket tests are really fragile, but avoiding timeouts might be hard, since it's testing stuff on the network. " +
50 "Expect all sorts of flakiness in this test...");
51 SimpleTest.waitForExplicitFinish();