Bug 1575493 - Create a RequestContext in the HTTP fuzzing target. r=mayhemer
☠☠ backed out by 6ec4fe140cf1 ☠ ☠
authorChristian Holler <choller@mozilla.com>
Wed, 21 Aug 2019 11:12:39 +0000
changeset 489165 4e11ff3ee0e72b60cea6f1c886e8dcd0ffdceaa9
parent 489164 dfdbefcf317c5627b5487e5c9581c551bc23fd5c
child 489166 d486a73f335879d316a5daf9d77da8fe693e7f85
push id36465
push userdvarga@mozilla.com
push dateWed, 21 Aug 2019 16:47:43 +0000
treeherdermozilla-central@4ab60925635c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1575493
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575493 - Create a RequestContext in the HTTP fuzzing target. r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D42815
netwerk/test/fuzz/TestHttpFuzzing.cpp
--- a/netwerk/test/fuzz/TestHttpFuzzing.cpp
+++ b/netwerk/test/fuzz/TestHttpFuzzing.cpp
@@ -6,16 +6,17 @@
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsIPrincipal.h"
 #include "nsScriptSecurityManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsNetUtil.h"
 #include "NullPrincipal.h"
 #include "nsCycleCollector.h"
+#include "RequestContextService.h"
 
 #include "FuzzingInterface.h"
 
 namespace mozilla {
 namespace net {
 
 // Used to determine if the fuzzing target should use https:// in spec.
 static bool fuzzHttps = false;
@@ -141,16 +142,26 @@ static int FuzzingRunNetworkHttp(const u
     nsCOMPtr<nsIHttpChannel> gHttpChannel;
 
     gHttpChannel = do_QueryInterface(channel);
     rv = gHttpChannel->SetRequestMethod(NS_LITERAL_CSTRING("GET"));
     if (rv != NS_OK) {
       MOZ_CRASH("SetRequestMethod on gHttpChannel failed.");
     }
 
+    nsCOMPtr<nsIRequestContextService> rcsvc =
+        mozilla::net::RequestContextService::GetOrCreate();
+    nsCOMPtr<nsIRequestContext> rc;
+    rv = rcsvc->NewRequestContext(getter_AddRefs(rc));
+    if (rv != NS_OK) {
+      MOZ_CRASH("NewRequestContext failed.");
+    }
+
+    gHttpChannel->SetRequestContextID(rc->GetID());
+
     gStreamListener = new FuzzingStreamListener();
     gHttpChannel->AsyncOpen(gStreamListener);
 
     // Wait for StopRequest
     gStreamListener->waitUntilDone();
 
     channelRef = do_GetWeakReference(gHttpChannel);
   }