summaryrefslogtreecommitdiffstats
path: root/dom/websocket/tests/iframe_websocket_wss.html
blob: 817b3866242512dc7a44c5c575164711f9be74a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<html><body>
Creating WebSocket
<script type="application/javascript">
onmessage = function(e) {
  parent.postMessage(e.data, '*');
}

try{
  let socket;
  if (location.search == '?insecure') {
    socket = new WebSocket('ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello');
  }
  else {
    socket = new WebSocket('wss://example.com/tests/dom/websocket/tests/file_websocket_hello');
  }
  socket.onerror = function(e) {
    parent.postMessage('WS onerror', '*');
    close();
  };
  socket.onopen = function(e) {
    socket.close();
    parent.postMessage('WS onopen', '*');
    close();
  };
} catch(e) {
  if (e.name == 'SecurityError') {
    parent.postMessage('SecurityError', '*');
  } else {
    parent.postMessage('WS Throws something else!', '*');
  }
  close();
}

</script>
</body></html>