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