Bug 1227136 - test for the crash, r=bagder, a=ritu
authorMichal Novotny <michal.novotny@gmail.com>
Wed, 30 Mar 2016 13:10:05 +0200
changeset 310344 435e4e199131c10583596524bf79cf1120e6a795
parent 310343 46df2ac4c6b4e9ca7cb48f2c920a8678b332c2c4
child 310345 0d35bb93eda6e42aefe822fd8106496450f33168
push id9337
push usermnovotny@mozilla.com
push dateWed, 30 Mar 2016 11:10:13 +0000
treeherdermozilla-aurora@435e4e199131 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder, ritu
bugs1227136
milestone47.0a2
Bug 1227136 - test for the crash, r=bagder, a=ritu
dom/base/test/test_websocket5.html
--- a/dom/base/test/test_websocket5.html
+++ b/dom/base/test/test_websocket5.html
@@ -265,24 +265,53 @@ function test47() {
     ws._withinClose = 1;
     ws.close(3333, "Closed before we were open: error");
     ws._withinClose = 0;
     is(ws.readyState, 2, "test-47: readyState should be CLOSING(2) after close(): got "
        + ws.readyState);
   });
 }
 
+function test48() {
+  return new Promise(function(resolve, reject) {
+    const pref_close = "network.websocket.timeout.close";
+    SpecialPowers.setIntPref(pref_close, 1);
+
+    var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-48");
+
+    ws.onopen = function() {
+      ws.close();
+
+      var date = new Date();
+      var curDate = null;
+      do {
+        curDate = new Date();
+      } while(curDate-date < 1500);
+
+    }
+
+    ws.onclose = function(e) {
+      ok(true, "ws close in test 48");
+      resolve();
+    }
+
+    SpecialPowers.clearUserPref(pref_close);
+  });
+}
+
 var tests = [
   test41, // HSTS
   test42, // non-char utf-8 sequences
   test43, // Test setting binaryType attribute
   test44, // Test sending/receving binary ArrayBuffer
   test45, // Test sending/receving binary Blob
   test46, // Test that we don't dispatch incoming msgs once in CLOSING state
   test47, // Make sure onerror/onclose aren't called during close()
+  test48, // see bug 1227136 - client calls close() from onopen() and waits
+          // until WebSocketChannel::mSocketIn is nulled out on socket thread
 ];
 
 function testWebSocket() {
   doTest();
 }
 
 </script>