Bug 1305162: Part 3 - Allow requestBody in release builds. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Fri, 09 Dec 2016 14:37:48 -1000
changeset 375561 8812f239cc29e7c3460db4a62180bca0cf4bc921
parent 375560 2d7a7af68b7522cc3886d369c40639098e73c4af
child 375562 dc5a594e63f27286ea6a8485075fda431c936ddd
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1305162
milestone53.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 1305162: Part 3 - Allow requestBody in release builds. r=mixedpuppy MozReview-Commit-ID: AmlVoDduXHf
toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html
toolkit/modules/addons/WebRequest.jsm
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html
@@ -64,24 +64,23 @@ add_task(function* test_setup() {
     [blob.name]: blob,
     [file.name]: file,
   };
 });
 
 function background() {
   const FILTERS = {urls: ["<all_urls>"]};
 
-  let requestBodySupported = true;
-
   function onUpload(details) {
     let url = new URL(details.url);
     let upload = url.searchParams.get("upload");
-    if (!upload || !requestBodySupported) {
+    if (!upload) {
       return;
     }
+
     let requestBody = details.requestBody;
     browser.test.log(`onBeforeRequest upload: ${details.url} ${JSON.stringify(details.requestBody)}`);
     browser.test.assertTrue(!!requestBody, `Intercepted upload ${details.url} #${details.requestId} ${upload} have a requestBody`);
     if (!requestBody) {
       return;
     }
     let byteLength = parseInt(upload, 10);
     if (byteLength) {
@@ -105,31 +104,18 @@ function background() {
     FILTERS);
 
   let onBeforeRequest = details => {
     browser.test.log(`${name} ${details.requestId} ${details.url}`);
 
     onUpload(details);
   };
 
-  try {
-    browser.webRequest.onBeforeRequest.addListener(
-      onBeforeRequest, FILTERS, ["requestBody"]);
-  } catch (e) {
-    browser.test.assertTrue(/\brequestBody\b/.test(e.message),
-                            "Request body is unsupported");
-
-    // requestBody is disabled in release builds
-    if (!/\brequestBody\b/.test(e.message)) {
-      throw e;
-    }
-
-    browser.webRequest.onBeforeRequest.addListener(
-      onBeforeRequest, FILTERS);
-  }
+  browser.webRequest.onBeforeRequest.addListener(
+    onBeforeRequest, FILTERS, ["requestBody"]);
 }
 
 add_task(function* test_xhr_forms() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: [
         "webRequest",
         "webRequestBlocking",
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -14,18 +14,16 @@ const Cu = Components.utils;
 const Cr = Components.results;
 
 const {nsIHttpActivityObserver, nsISocketTransport} = Ci;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
-                                  "resource://gre/modules/AppConstants.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
                                   "resource://gre/modules/BrowserUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionUtils",
                                   "resource://gre/modules/ExtensionUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "WebRequestCommon",
                                   "resource://gre/modules/WebRequestCommon.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "WebRequestUpload",
                                   "resource://gre/modules/WebRequestUpload.jsm");
@@ -852,24 +850,18 @@ HttpObserverManager = {
   },
 
   onStopRequest(channel, loadContext) {
     this.runChannelListener(channel, loadContext, "onStop");
   },
 };
 
 var onBeforeRequest = {
-  get allowedOptions() {
-    delete this.allowedOptions;
-    this.allowedOptions = ["blocking"];
-    if (!AppConstants.RELEASE_OR_BETA) {
-      this.allowedOptions.push("requestBody");
-    }
-    return this.allowedOptions;
-  },
+  allowedOptions: ["blocking", "requestBody"],
+
   addListener(callback, filter = null, opt_extraInfoSpec = null) {
     let opts = parseExtra(opt_extraInfoSpec, this.allowedOptions);
     opts.filter = parseFilter(filter);
     ContentPolicyManager.addListener(callback, opts);
     HttpObserverManager.addListener("opening", callback, opts);
   },
 
   removeListener(callback) {