| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="/js-test-resources/js-test-pre.js"></script> | 4 <script src="/js-test-resources/js-test-pre.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <div id="description"></div> | 7 <div id="description"></div> |
| 8 <div id="console"></div> | 8 <div id="console"></div> |
| 9 <script type="text/javascript"> | 9 <script type="text/javascript"> |
| 10 description("Test if Web Socket opened in iframe, referred in parent document is
, and try to send() returns false."); | 10 description("Test if Web Socket opened in iframe, referred in parent document is
, and try to send() returns false."); |
| 11 | 11 |
| 12 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
| 13 | 13 |
| 14 var frameDiv; | 14 var frameDiv; |
| 15 var closedSocket; | 15 var closedSocket; |
| 16 var closeCode; |
| 16 document.childWebSocket = null; | 17 document.childWebSocket = null; |
| 17 | 18 |
| 18 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-on-unload
"); | 19 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-on-unload
"); |
| 19 ws.onopen = function() | 20 ws.onopen = function() |
| 20 { | 21 { |
| 21 debug("PASS ws on master document is ready."); | 22 debug("PASS ws on master document is ready."); |
| 22 frameDiv = document.createElement("iframe"); | 23 frameDiv = document.createElement("iframe"); |
| 23 frameDiv.src = "resources/close-on-unload-iframe-reference-in-parent.html"; | 24 frameDiv.src = "resources/close-on-unload-iframe-reference-in-parent.html"; |
| 24 document.body.appendChild(frameDiv); | 25 document.body.appendChild(frameDiv); |
| 25 debug("PASS insert a iframe, where open ws called 'socket1'"); | 26 debug("PASS insert a iframe, where open ws called 'socket1'"); |
| 26 }; | 27 }; |
| 27 ws.onmessage = function(evt) | 28 ws.onmessage = function(evt) |
| 28 { | 29 { |
| 29 closedSocket = evt.data; | 30 var messageData = JSON.parse(evt.data); |
| 31 closedSocket = messageData.message; |
| 32 closeCode = messageData.closeCode; |
| 30 ws.close(); | 33 ws.close(); |
| 31 }; | 34 }; |
| 32 ws.onclose = function() | 35 ws.onclose = function() |
| 33 { | 36 { |
| 34 shouldBe("closedSocket", '"socket1"'); | 37 shouldBe("closedSocket", '"socket1"'); |
| 38 shouldBe("closeCode", '"1001"'); |
| 35 shouldBe("document.childWebSocket.readyState", "3"); | 39 shouldBe("document.childWebSocket.readyState", "3"); |
| 36 finishJSTest(); | 40 finishJSTest(); |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 document.iframeReady = function() | 43 document.iframeReady = function() |
| 40 { | 44 { |
| 41 shouldBeNonNull("document.childWebSocket"); | 45 shouldBeNonNull("document.childWebSocket"); |
| 42 debug("PASS 'socket1' is sent to the server. unload the iframe. expect recei
ving 'socket1' on ws..."); | 46 debug("PASS 'socket1' is sent to the server. unload the iframe. expect recei
ving 'socket1' on ws..."); |
| 43 document.body.removeChild(frameDiv); | 47 document.body.removeChild(frameDiv); |
| 44 shouldBeUndefined("document.childWebSocket.send('send to closed socket')"); | 48 shouldBeUndefined("document.childWebSocket.send('send to closed socket')"); |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 </script> | 51 </script> |
| 48 <script src="/js-test-resources/js-test-post.js"></script> | 52 <script src="/js-test-resources/js-test-post.js"></script> |
| 49 </body> | 53 </body> |
| 50 </html> | 54 </html> |
| OLD | NEW |