html_ws-sse-test-page.html (1926B)
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/SSE Inspection Test Page</title> 11 </head> 12 <body> 13 <h1>WebSocket/SSE Inspection Test Page</h1> 14 <script type="text/javascript"> 15 /* exported openWsConnection, openSseConnection, closeWsConnection, sendData */ 16 "use strict"; 17 18 let ws; 19 function openWsConnection(numFramesToSend) { 20 return new Promise(resolve => { 21 ws = new WebSocket( 22 "ws://mochi.test:8888/browser/devtools/client/netmonitor/test/file_ws_backend" 23 ); 24 25 ws.onopen = () => { 26 for (let i = 0; i < numFramesToSend; i++) { 27 ws.send("Payload " + i); 28 } 29 resolve(); 30 }; 31 }); 32 } 33 34 function closeWsConnection() { 35 return new Promise(resolve => { 36 ws.onclose = () => { 37 resolve(); 38 }; 39 ws.close(); 40 }); 41 } 42 43 function sendData(payload) { 44 ws.send(payload); 45 } 46 47 let es; 48 function openSseConnection() { 49 return new Promise(resolve => { 50 es = new EventSource("http://mochi.test:8888/browser/devtools/client/netmonitor/test/sjs_sse-test-server.sjs"); 51 es.onmessage = function() { 52 es.close(); 53 resolve(); 54 }; 55 }); 56 } 57 </script> 58 </body> 59 </html>