Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: LayoutTests/http/tests/websocket/tests/hybi/close-on-unload-reference-in-parent.html

Issue 23069004: Check WebSocket close code sent on unload (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating the code comments for landing Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 but referred in parent document is closed on unloading the frame."); 10 description("Test if Web Socket opened in iframe but referred in parent document is closed on unloading the frame.");
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 }; 48 };
45 49
46 </script> 50 </script>
47 <script src="/js-test-resources/js-test-post.js"></script> 51 <script src="/js-test-resources/js-test-post.js"></script>
48 </body> 52 </body>
49 </html> 53 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698