summaryrefslogtreecommitdiffstats
path: root/net/data/websocket/proxied_request_check.html
blob: 9d6d64edbe1ab769395e852a7163ae46a5f4dc1a (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
<!DOCTYPE html>
<head>
<title>test proxied ws connection</title>
</head>
<script type="text/javascript">
// Do connection test and check the headers arrive at the WebSocket.

var protocol = location.protocol.replace('http', 'ws');
var url = protocol + '//' + location.host + '/echo-request-headers';
var ws = new WebSocket(url);

ws.onmessage = function(evt)
{
  var headers = JSON.parse(evt.data);
  for (var name in headers) {
    // The keys in the serialized data are lower cased.
    if (name.startsWith('proxy-')) {
      document.title = 'FAIL';
      return;
    }
  }

  // Set document title to 'PASS'. The test observer catches this title changes
  // to know the result.
  document.title = 'PASS';
}

ws.onclose = function()
{
  document.title = 'FAIL';
}
</script>