diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 5c40ca543dcc..f9dcabb63c04 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -446,6 +446,7 @@ nsHttpConnectionMgr::LookupConnectionEntry(nsHttpConnectionInfo *ci, nsHttpConnection *conn, nsHttpTransaction *trans) { + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); if (!ci) return nullptr; @@ -574,6 +575,8 @@ void nsHttpConnectionMgr::ReportSpdyCWNDSetting(nsHttpConnectionInfo *ci, uint32_t cwndValue) { + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); + if (!gHttpHandler->UseSpdyPersistentSettings()) return; @@ -600,6 +603,8 @@ nsHttpConnectionMgr::ReportSpdyCWNDSetting(nsHttpConnectionInfo *ci, uint32_t nsHttpConnectionMgr::GetSpdyCWNDSetting(nsHttpConnectionInfo *ci) { + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); + if (!gHttpHandler->UseSpdyPersistentSettings()) return 0; @@ -886,6 +891,7 @@ nsHttpConnectionMgr::PruneDeadConnectionsCB(const nsACString &key, nsAutoPtr &ent, void *closure) { + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); nsHttpConnectionMgr *self = (nsHttpConnectionMgr *) closure; LOG((" pruning [ci=%s]\n", ent->mConnInfo->HashKey().get())); @@ -2222,6 +2228,7 @@ void nsHttpConnectionMgr::OnMsgClosePersistentConnections(int32_t, void *) { LOG(("nsHttpConnectionMgr::OnMsgClosePersistentConnections\n")); + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); mCT.Enumerate(ClosePersistentConnectionsCB, this); } @@ -3387,6 +3394,7 @@ nsHttpConnectionMgr::GetConnectionData(nsTArray *aA void nsHttpConnectionMgr::ResetIPFamillyPreference(nsHttpConnectionInfo *ci) { + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); nsConnectionEntry *ent = LookupConnectionEntry(ci, nullptr, nullptr); if (ent) ent->ResetIPFamilyPreference(); diff --git a/netwerk/test/unit/test_freshconnection.js b/netwerk/test/unit/test_freshconnection.js new file mode 100644 index 000000000000..cf92c4d40a56 --- /dev/null +++ b/netwerk/test/unit/test_freshconnection.js @@ -0,0 +1,31 @@ +// This is essentially a debug mode crashtest to make sure everything +// involved in a reload runs on the right thread. It relies on the +// assertions in necko. + +const Cc = Components.classes; +const Ci = Components.interfaces; + +var listener = { + onStartRequest: function test_onStartR(request, ctx) { + }, + + onDataAvailable: function test_ODA() { + do_throw("Should not get any data!"); + }, + + onStopRequest: function test_onStopR(request, ctx, status) { + do_test_finished(); + }, +}; + +function run_test() { + var ios = Cc["@mozilla.org/network/io-service;1"]. + getService(Ci.nsIIOService); + var chan = ios.newChannel("http://localhost:4444", "", null); + chan.loadFlags = Ci.nsIRequest.LOAD_FRESH_CONNECTION | + Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI; + chan.QueryInterface(Ci.nsIHttpChannel); + chan.asyncOpen(listener, null); + do_test_pending(); +} + diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini index 41f97ba2279c..63dcfbc594d8 100644 --- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -107,6 +107,7 @@ tail = [test_file_partial_inputstream.js] [test_file_protocol.js] [test_filestreams.js] +[test_freshconnection.js] [test_gre_resources.js] [test_gzipped_206.js] [test_head.js]