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

Side by Side Diff: LayoutTests/http/tests/websocket/tests/hybi/close-on-unload-and-force-gc.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, 4 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 is closed on unload and not crashed if garbage c ollected"); 10 description("Test if Web Socket is closed on unload and not crashed if garbage c ollected");
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 17
17 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-on-unload "); 18 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/close-on-unload ");
18 ws.onopen = function() 19 ws.onopen = function()
19 { 20 {
20 debug("PASS ws on master document is ready."); 21 debug("PASS ws on master document is ready.");
21 frameDiv = document.createElement("iframe"); 22 frameDiv = document.createElement("iframe");
22 frameDiv.src = "resources/close-on-unload-iframe.html"; 23 frameDiv.src = "resources/close-on-unload-iframe.html";
23 document.body.appendChild(frameDiv); 24 document.body.appendChild(frameDiv);
24 debug("PASS insert a iframe, where open ws called 'socket1'"); 25 debug("PASS insert a iframe, where open ws called 'socket1'");
25 }; 26 };
26 ws.onmessage = function(evt) 27 ws.onmessage = function(evt)
27 { 28 {
28 closedSocket = evt.data; 29 var messageData = JSON.parse(evt.data);
30 closedSocket = messageData.message;
31 closeCode = messageData.closeCode;
29 ws.close(); 32 ws.close();
30 }; 33 };
31 ws.onclose = function() 34 ws.onclose = function()
32 { 35 {
33 shouldBe("closedSocket", '"socket1"'); 36 shouldBe("closedSocket", '"socket1"');
37 shouldBe("closeCode", '"1001"');
34 finishJSTest(); 38 finishJSTest();
35 }; 39 };
36 40
37 document.iframeReady = function() 41 document.iframeReady = function()
38 { 42 {
39 debug("PASS 'socket1' is sent to the server. unload the iframe and force gar bage collection. expect receiving 'socket1' on ws and no crash..."); 43 debug("PASS 'socket1' is sent to the server. unload the iframe and force gar bage collection. expect receiving 'socket1' on ws and no crash...");
40 document.body.removeChild(frameDiv); 44 document.body.removeChild(frameDiv);
41 gc(); 45 gc();
42 }; 46 };
43 47
44 </script> 48 </script>
45 <script src="/js-test-resources/js-test-post.js"></script> 49 <script src="/js-test-resources/js-test-post.js"></script>
46 </body> 50 </body>
47 </html> 51 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698