Bug 851471 - Part 1 - Remove the MOZ_JSDOWNLOADS configure option. r=mak draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Fri, 05 May 2017 12:16:42 +0100
changeset 574295 65f1cb5acf55f01cb1c23b47dcfaed9d9690ee80
parent 574294 0931839a3e5bb8393c95854f75f0b1e5098703e3
child 574296 732f559570df777190e91edd8d59d10e3d510adb
push id57640
push userpaolo.mozmail@amadzone.org
push dateMon, 08 May 2017 15:59:15 +0000
reviewersmak
bugs851471
milestone55.0a1
Bug 851471 - Part 1 - Remove the MOZ_JSDOWNLOADS configure option. r=mak MozReview-Commit-ID: B73Ym5tD06R
browser/confvars.sh
old-configure.in
toolkit/components/downloads/nsDownloadManager.cpp
uriloader/exthandler/tests/moz.build
uriloader/exthandler/tests/unit_ipc/test_encoding.js
uriloader/exthandler/tests/unit_ipc/xpcshell.ini
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -55,15 +55,14 @@ MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3
 if test "$MOZ_UPDATE_CHANNEL" = "aurora"; then
   ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-aurora
   MAR_CHANNEL_ID=firefox-mozilla-aurora
 else
   ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-central
   MAR_CHANNEL_ID=firefox-mozilla-central
 fi
 MOZ_PROFILE_MIGRATOR=1
-MOZ_JSDOWNLOADS=1
 
 # Enable checking that add-ons are signed by the trusted root
 MOZ_ADDON_SIGNING=1
 
 # Include the DevTools client, not just the server (which is the default)
 MOZ_DEVTOOLS=all
--- a/old-configure.in
+++ b/old-configure.in
@@ -5013,21 +5013,16 @@ AC_SUBST(MOZ_ADDON_SIGNING)
 if test "$MOZ_ADDON_SIGNING" = 1; then
   AC_DEFINE(MOZ_ADDON_SIGNING)
 fi
 AC_SUBST(MOZ_REQUIRE_SIGNING)
 if test "$MOZ_REQUIRE_SIGNING" = 1; then
   AC_DEFINE(MOZ_REQUIRE_SIGNING)
 fi
 
-AC_SUBST(MOZ_JSDOWNLOADS)
-if test -n "$MOZ_JSDOWNLOADS"; then
-  AC_DEFINE(MOZ_JSDOWNLOADS)
-fi
-
 dnl ========================================================
 dnl = Mac bundle name prefix
 dnl ========================================================
 MOZ_ARG_WITH_STRING(macbundlename-prefix,
 [  --with-macbundlename-prefix=prefix
                           Prefix for MOZ_MACBUNDLE_NAME],
 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
 
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -953,23 +953,17 @@ nsDownloadManager::Init()
     mozilla::services::GetStringBundleService();
   if (!bundleService)
     return NS_ERROR_FAILURE;
 
   rv = bundleService->CreateBundle(DOWNLOAD_MANAGER_BUNDLE,
                                    getter_AddRefs(mBundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
-#if !defined(MOZ_JSDOWNLOADS)
-  // When MOZ_JSDOWNLOADS is undefined, we still check the preference that can
-  // be used to enable the JavaScript API during the migration process.
-  mUseJSTransfer = Preferences::GetBool(PREF_BD_USEJSTRANSFER, false);
-#else
   mUseJSTransfer = true;
-#endif
 
   if (mUseJSTransfer)
     return NS_OK;
 
   // Clean up any old downloads.rdf files from before Firefox 3
   {
     nsCOMPtr<nsIFile> oldDownloadsFile;
     bool fileExists;
--- a/uriloader/exthandler/tests/moz.build
+++ b/uriloader/exthandler/tests/moz.build
@@ -5,21 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOCHITEST_MANIFESTS += ['mochitest/mochitest.ini']
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 BROWSER_CHROME_MANIFESTS += ['mochitest/browser.ini']
 
-# The encoding test is already implemented in the Downloads API by a set of
-# test cases with the string "content_encoding" in their names.
-if not CONFIG['MOZ_JSDOWNLOADS']:
-    XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
-
 TESTING_JS_MODULES += [
     'HandlerServiceTestUtils.jsm',
 ]
 
 GeckoSimplePrograms([
     'WriteArgument',
 ], linkage=None)
 
deleted file mode 100644
--- a/uriloader/exthandler/tests/unit_ipc/test_encoding.js
+++ /dev/null
@@ -1,231 +0,0 @@
-
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
-
-Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/NetUtil.jsm");
-Cu.import("resource://testing-common/MockRegistrar.js");
-
-do_get_profile();
-
-var DownloadListener = {
-  init: function () {
-    let obs = Services.obs;
-    obs.addObserver(this, "dl-done", true);
-  },
-
-  observe: function (subject, topic, data) {
-    this.onFinished(subject, topic, data);
-  },
-
-  QueryInterface: function (iid) {
-    if (iid.equals(Ci.nsIObserver) ||
-        iid.equals(Ci.nsISupportsWeakReference) ||
-        iid.equals(Ci.nsISupports))
-      return this;
-
-    throw Cr.NS_ERROR_NO_INTERFACE;
-  }
-}
-DownloadListener.init();
-
-function HelperAppDlg() { }
-HelperAppDlg.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
-  show: function (launcher, ctx, reason, usePrivateUI) {
-    launcher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToFile;
-    launcher.launchWithApplication(null, false);
-  }
-}
-
-// Override the download-manager-ui to prevent anyone from trying to open
-// a window.
-function DownloadMgrUI() { }
-DownloadMgrUI.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadManagerUI]),
-  show: function (ir, aID, reason) { },
-
-  visible: false,
-
-  getAttention: function () { }
-}
-
-function AlertsSVC() { }
-AlertsSVC.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAlertsService]),
-  showAlertNotification: function (url, title, text, clickable, cookie, listener, name) { },
-}
-
-MockRegistrar.register("@mozilla.org/helperapplauncherdialog;1",
-                       HelperAppDlg);
-MockRegistrar.register("@mozilla.org/download-manager-ui;1",
-                       DownloadMgrUI);
-MockRegistrar.register("@mozilla.org/alerts-service;1",
-                       AlertsSVC);
-
-function initChildTestEnv()
-{
-  sendCommand('                                                                \
-    const Cc = Components.classes;                                             \
-    const Ci = Components.interfaces;                                          \
-    const Cr = Components.results;                                             \
-    const Cu = Components.utils;                                               \
-    Cu.import("resource://gre/modules/Services.jsm");                          \
-    function WindowContext() { }                                               \
-                                                                               \
-    WindowContext.prototype = {                                                \
-      getInterface: function (iid) {                                           \
-        if (iid.equals(Ci.nsIInterfaceRequestor) ||                            \
-            iid.equals(Ci.nsIURIContentListener) ||                            \
-            iid.equals(Ci.nsILoadGroup) ||                                     \
-            iid.equals(Ci.nsIDocumentLoader) ||                                \
-            iid.equals(Ci.nsIDOMWindow))                                       \
-          return this;                                                         \
-                                                                               \
-        throw Cr.NS_ERROR_NO_INTERFACE;                                        \
-      },                                                                       \
-                                                                               \
-      /* nsIURIContentListener */                                              \
-      onStartURIOpen: function (uri) { },                                      \
-      isPreferred: function (type, desiredtype) { return false; },             \
-                                                                               \
-      /* nsILoadGroup */                                                       \
-      addRequest: function (request, context) { },                             \
-      removeRequest: function (request, context, status) { }                   \
-    };                                                                         \
-                                                                               \
-    var ioservice = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);\
-    var uriloader = Cc["@mozilla.org/uriloader;1"].getService(Ci.nsIURILoader);\
-  ');
-}
-
-function testFinisher(endFunc) {
-  let ef = endFunc;
-  return function (file) {
-    ef(file);
-    runNextTest();
-  }
-}
-
-function runChildTestSet(set)
-{
-  DownloadListener.onFinished = testFinisher(set[2]);
-  sendCommand('\
-  let uri = ioservice.newURI("http://localhost:4444' + set[0] + '", null, null);          \
-  let channel = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});           \
-  uriloader.openURI(channel, Ci.nsIURILoader.IS_CONTENT_PREFERRED, new WindowContext());  \
-  ');
-}
-
-var httpserver = null;
-var currentTest = 0;
-function runNextTest()
-{
-  if (currentTest == tests.length) {
-    httpserver.stop(do_test_finished);
-    return;
-  }
-
-  let set = tests[currentTest++];
-  runChildTestSet(set);
-}
-
-const responseBody = [0x1f, 0x8b, 0x08, 0x00, 0x16, 0x5a, 0x8a, 0x48, 0x02,
-		      0x03, 0x2b, 0x49, 0x2d, 0x2e, 0xe1, 0x02, 0x00, 0xc6,
-		      0x35, 0xb9, 0x3b, 0x05, 0x00, 0x00, 0x00];
-
-/*
- * First test:  a file with Content-Type application/x-gzip and Content-Encoding gzip
- * should not be decoded in a round-trip
- */
-function testResponse1(metadata, response) {
-  response.setHeader("Content-Type", "application/x-gzip", false);
-  response.setHeader("Content-Encoding", "gzip", false);
-  response.setHeader("Content-Disposition", "attachment", false);
-
-  var bos = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(Ci.nsIBinaryOutputStream);
-  bos.setOutputStream(response.bodyOutputStream);
-  bos.writeByteArray(responseBody, responseBody.length);
-}
-
-function finishTest1(subject, topic, data) {
-  let file = subject.QueryInterface(Ci.nsIDownload).targetFile;
-  do_check_true(file.path.search("test1.gz") != 0);
-  let fis = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
-  fis.init(file, -1, -1, 0);
-  let bis = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
-  bis.setInputStream(fis);
-  let str = bis.readByteArray(bis.available());
-  do_check_matches(str, responseBody);
-}
-
-/*
- * Second test:  a file with Content-Type text/html and Content-Encoding gzip
- * should not be decoded in a round-trip, if its filename ends in ".gz".
- * We specify a Content-disposition header to force it to be saved as a file.
- */
-function testResponse2(metadata, response) {
-  response.setHeader("Content-Type", "text/html", false);
-  response.setHeader("Content-Encoding", "gzip", false);
-  response.setHeader("Content-Disposition", "attachment", false);
-
-  var bos = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(Ci.nsIBinaryOutputStream);
-  bos.setOutputStream(response.bodyOutputStream);
-  bos.writeByteArray(responseBody, responseBody.length);
-}
-
-function finishTest2(subject, topic, data) {
-  let file = subject.QueryInterface(Ci.nsIDownload).targetFile;
-  do_check_true(file.path.search("test2.gz") != 0);
-  let fis = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
-  fis.init(file, -1, -1, 0);
-  let bis = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
-  bis.setInputStream(fis);
-  let str = bis.readByteArray(bis.available());
-  do_check_matches(str, responseBody);
-}
-
-function testResponse3(metadata, response) {
-  response.setHeader("Content-Type", "text/html", false);
-  response.setHeader("Content-Encoding", "gzip", false);
-  response.setHeader("Content-Disposition", "attachment", false);
-
-  var bos = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(Ci.nsIBinaryOutputStream);
-  bos.setOutputStream(response.bodyOutputStream);
-  bos.writeByteArray(responseBody, responseBody.length);
-}
-
-function finishTest3(subject, topic, data) {
-  let file = subject.QueryInterface(Ci.nsIDownload).targetFile;
-  do_check_true(file.path.search("test3.txt") != 0);
-  let fis = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
-  fis.init(file, -1, -1, 0);
-  let bis = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
-  bis.setInputStream(fis);
-  let str = bis.readByteArray(bis.available());
-  let decodedBody = [ 116, 101, 115, 116, 10 ]; // 't','e','s','t','\n'
-  do_check_matches(str, decodedBody);
-}
-
-var tests = [
-  [ "/test1.gz", testResponse1, finishTest1 ],
-  [ "/test2.gz", testResponse2, finishTest2 ],
-  [ "/test3.txt", testResponse3, finishTest3 ],
-];
-
-function run_test() {
-//  do_load_child_test_harness();
-  httpserver = new HttpServer();
-  httpserver.start(4444);
-  do_test_pending();
-
-  initChildTestEnv();
-
-  for (let set of tests)
-    httpserver.registerPathHandler(set[0], set[1]);
-
-  runNextTest();
-}
deleted file mode 100644
--- a/uriloader/exthandler/tests/unit_ipc/xpcshell.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[DEFAULT]
-head = 
-
-[test_encoding.js]
-# Bug 676995: test hangs consistently on Android
-# Bug 907732: thunderbird still uses legacy downloads manager.
-skip-if = (os == "android" || buildapp == '../mail')