summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/websockets/interfaces/WebSocket/constants/002.html
blob: 6810bc6c292092c66375083bd1bb3443664911a3 (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
<!doctype html>
<title>WebSockets: setting constants</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../../constants.sub.js></script>
<meta name="variant" content="?default">
<meta name="variant" content="?wss">
<div id=log></div>
<script>
// this test is testing WebIDL stuff
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/');
var constants = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
for (var i = 0; i < constants.length; ++i) {
  test(function() {
    WebSocket[constants[i]] = 5; // should be ignored, has { ReadOnly }
    WebSocket.prototype[constants[i]] = 5; // should be ignored, has { ReadOnly }
    ws[constants[i]] = 5; // should be ignored, { ReadOnly } is inherited from prototype
    assert_equals(WebSocket[constants[i]], i, 'WebSocket.'+constants[i]);
    assert_equals(WebSocket.prototype[constants[i]], i, 'WebSocket.prototype.'+constants[i]);
    assert_equals(ws[constants[i]], i, 'ws.'+constants[i]);
  }, "Readonly constants " + constants[i]);
};
</script>