Commit f0418a0c authored by Michal Novotny's avatar Michal Novotny
Browse files

Bug 1227136 - test for the crash, r=bagder

parent cccdd9fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ var tests = [
  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() {
+29 −0
Original line number Diff line number Diff line
@@ -1213,3 +1213,32 @@ function test47() {
       + ws.readyState);
  });
}

// test48: see bug 1227136 - client calls close() from onopen() and waits until
// WebSocketChannel::mSocketIn is nulled out on socket thread.
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);
  });
}