096f52ebdd9f8e4454c9ea63b693296d7f6f04cb
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / 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("Web Socket Cross Origin test");
11
12 window.jsTestIsAsync = true;
13
14 var origin;
15
16 function endTest()
17 {
18     shouldBe("origin", '"http://127.0.0.1:8000"');
19     clearTimeout(timeoutID);
20     finishJSTest();
21 }
22
23 var url = "ws://localhost:8880/websocket/tests/hixie76/origin-test";
24 debug("document.domain=" + document.domain);
25 debug("ws.url=" + url);
26 var ws = new WebSocket(url);
27
28 ws.onopen = function()
29 {
30     debug("Connected");
31 };
32
33 ws.onmessage = function (messageEvent)
34 {
35     origin = messageEvent.data;
36     ws.close();
37 };
38
39 ws.onclose = function()
40 {
41     endTest();
42 };
43
44 function timeOutCallback()
45 {
46     debug("Timed out in state: " + ws.readyState);
47     endTest();
48 }
49
50 var timeoutID = setTimeout(timeOutCallback, 3000);
51
52 var successfullyParsed = true;
53 </script>
54 <script src="../../../../js-test-resources/js-test-post.js"></script>
55 </body>
56 </html>