Bug 1305162: Part 3 - Allow requestBody in release builds. r=mixedpuppy
☠☠ backed out by 81824fdf77fb ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Fri, 09 Dec 2016 14:37:48 -1000
changeset 330534 c633650caea682de11142d5cb6d28f3effcadf55
parent 330533 1a23ce5a17c338a9ef902d4f30e586ad4444af36
child 330535 033dff7024f618a9a7014efa01eef3cd6a5d079e
push id36330
push userphilringnalda@gmail.com
push dateSat, 21 Jan 2017 23:26:41 +0000
treeherderautoland@5f0652e323af [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");
@@ -838,24 +836,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) {