bug 1038304 - websockets offline hang r=sworkman

This commit is contained in:
Patrick McManus 2014-07-17 11:56:38 -04:00
parent f4ad7f7695
commit d1f18d1c0c
3 changed files with 54 additions and 3 deletions

View File

@ -2425,11 +2425,16 @@ WebSocketChannel::OnProxyAvailable(nsICancelable *aRequest, nsIURI *aURI,
LOG(("WebSocket OnProxyAvailable [%p] Proxy found skip DNS lookup\n", this));
// call DNS callback directly without DNS resolver
OnLookupComplete(nullptr, nullptr, NS_ERROR_FAILURE);
return NS_OK;
} else {
LOG(("WebSocketChannel::OnProxyAvailable[%] checking DNS resolution\n", this));
nsresult rv = DoAdmissionDNS();
if (NS_FAILED(rv)) {
LOG(("WebSocket OnProxyAvailable [%p] DNS lookup failed\n", this));
// call DNS callback directly without DNS resolver
OnLookupComplete(nullptr, nullptr, NS_ERROR_FAILURE);
}
}
LOG(("WebSocketChannel::OnProxyAvailable[%] checking DNS resolution\n", this));
DoAdmissionDNS();
return NS_OK;
}

View File

@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Cu.import("resource://gre/modules/Services.jsm");
// checking to make sure we don't hang as per 1038304
// offline so url isn't impt
var url = "ws://localhost";
var chan;
var offlineStatus;
var listener = {
onAcknowledge: function(aContext, aSize) {},
onBinaryMessageAvailable: function(aContext, aMsg) {},
onMessageAvailable: function(aContext, aMsg) {},
onServerClose: function(aContext, aCode, aReason) {},
onStart: function(aContext)
{
// onStart is not called when a connection fails
do_check_true(false);
},
onStop: function(aContext, aStatusCode)
{
do_check_neq(aStatusCode, Cr.NS_OK);
Services.io.offline = offlineStatus;
do_test_finished();
}
};
function run_test() {
offlineStatus = Services.io.offline;
Services.io.offline = true;
try {
chan = Cc["@mozilla.org/network/protocol;1?name=ws"].
createInstance(Components.interfaces.nsIWebSocketChannel);
var uri = Services.io.newURI(url, null, null);
chan.asyncOpen(uri, url, listener, null);
do_test_pending();
} catch (x) {
dump("throwing " + x);
do_throw(x);
}
}

View File

@ -342,3 +342,4 @@ run-if = os == "win"
[test_udp_multicast.js]
[test_redirect_history.js]
[test_reply_without_content_type.js]
[test_websocket_offline.js]