f31e8dbb129a5950374fe1900ffeec8b730d6ec5
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / handshake-challenge-randomness.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../js-test-resources/js-test-style.css">
5 <script src="../../../js-test-resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
10 <script type="text/javascript">
11 description('Handshake request should contain random challenge values.');
12
13 window.jsTestIsAsync = true;
14
15 var challenge1;
16 var challenge2;
17
18 var url = 'ws://localhost:8880/websocket/tests/echo-challenge';
19 var ws1 = new WebSocket(url);
20
21 ws1.onmessage = function(messageEvent)
22 {
23     challenge1 = messageEvent.data;
24     ws1.close();
25 }
26
27 ws1.onclose = function()
28 {
29     var ws2 = new WebSocket(url);
30
31     ws2.onmessage = function(messageEvent)
32     {
33         challenge2 = messageEvent.data;
34         ws2.close();
35     }
36
37     ws2.onclose = function()
38     {
39         shouldBeFalse('challenge1 === challenge2');
40         if (challenge1 === challenge2)
41             debug('challenge was ' + challenge1);
42         finishJSTest();
43     }
44 }
45
46 var successfullyParsed = true;
47 </script>
48 <script src="../../../js-test-resources/js-test-post.js"></script>
49 </body>
50 </html>