Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / devtools / client / netmonitor / test / html_ws-test-page.html
blob7abcd033ed43db98159f96481ab86450ed611252
1 <!-- Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ -->
3 <!doctype HTML>
4 <html>
5 <head>
6 <meta charset="utf-8"/>
7 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
8 <meta http-equiv="Pragma" content="no-cache" />
9 <meta http-equiv="Expires" content="0" />
10 <title>WebSocket Inspection Test Page</title>
11 </head>
12 <body>
13 <h1>WebSocket Inspection Test Page</h1>
14 <script type="text/javascript">
15 /* exported openConnection, closeConnection, sendData, sendFrames */
16 "use strict";
18 let ws;
19 function openConnection(numFramesToSend) {
20 return new Promise(resolve => {
21 ws = new WebSocket(
22 "ws://mochi.test:8888/browser/devtools/client/netmonitor/test/file_ws_backend");
24 ws.onopen = () => {
25 for (let i = 0; i < numFramesToSend; i++) {
26 ws.send("Payload " + i);
28 resolve();
30 });
33 function sendFrames(numFramesToSend) {
34 return new Promise(resolve => {
35 for (let i = 0; i < numFramesToSend; i++) {
36 ws.send("Payload " + i);
38 resolve();
42 function closeConnection() {
43 return new Promise(resolve => {
44 ws.onclose = () => {
45 resolve();
47 ws.close();
51 function sendData(payload, asBinary = false) {
52 ws.send(
53 asBinary ? Uint8Array.from(payload, c => c.charCodeAt(0)) : payload
56 </script>
57 </body>
58 </html>