Threadsafety issues in WebScriptObject
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / handshake-fail-by-cross-origin.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../../js-test-resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
9 <script type="text/javascript">
10 description("Make sure Web Socket connection failed if origin mismatches.");
11
12 window.jsTestIsAsync = true;
13 if (window.layoutTestController)
14     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
15
16 var connected = false;
17 var origin;
18
19 function endTest()
20 {
21     shouldBeFalse("connected");
22     shouldBeUndefined("origin");
23     clearTimeout(timeoutID);
24     finishJSTest();
25 }
26
27 var url = "ws://localhost:8880/websocket/tests/hixie76/fixed-origin";
28 debug("document.domain=" + document.domain);
29 debug("ws.url=" + url);
30 var ws = new WebSocket(url);
31
32 ws.onopen = function()
33 {
34     debug("Connected");
35     connected = true;
36 };
37
38 ws.onmessage = function (messageEvent)
39 {
40     origin = messageEvent.data;
41     debug("origin=" + origin);
42     ws.close();
43 };
44
45 ws.onclose = function()
46 {
47     endTest();
48 };
49
50 function timeOutCallback()
51 {
52     debug("Timed out in state: " + ws.readyState);
53     endTest();
54 }
55
56 var timeoutID = setTimeout(timeOutCallback, 3000);
57
58 </script>
59 <script src="../../../../js-test-resources/js-test-post.js"></script>
60 </body>
61 </html>