• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<html>
3<head>
4<title>test ws connection</title>
5<script>
6
7const query = new URL(location.href).searchParams;
8
9async function test() {
10  try {
11    const port = query.get('port');
12    const ws = new WebSocket(`ws://127.0.0.1:${port}/check-origin`);
13    const ev = await new Promise((resolve, reject) => {
14      ws.onmessage = resolve;
15      ws.onclose = reject;
16    });
17    if (ev.data == 'file://') {
18      document.title = 'FILE';
19    } else if (ev.data == 'null') {
20      document.title = 'NULL';
21    } else {
22      document.title = 'FAIL';
23    }
24  } catch (e) {
25    document.title = 'FAIL';
26  }
27}
28
29test();
30
31</script>
32</head>
33</html>
34