Bug 1685822 [wpt PR 27117] - [Import Maps] Add tests for rejecting multiple import...
[gecko.git] / dom / websocket / tests / test_websocket_bigBlob.html
blob9db01d6a7f67f2de0efc49b5a898d43a009ef8c7
1 <!DOCTYPE HTML>
2 <html>
3 <head>
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" />
9 </head>
10 <body>
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')]));
22 let receivedBlob;
23 ws.onmessage = function(e) {
24 ok(e.data instanceof Blob, "We should be receiving a Blob");
25 receivedBlob = e.data;
26 ws.close();
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) {
43 SimpleTest.finish();
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();
53 </script>
54 </body>
55 </html>