Backed out 4 changesets (bug 1325501) for mass bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Wed, 04 Jan 2017 20:22:09 -0800
changeset 357080 f06afa54549bff3f2f03a8510334046c1050465a
parent 357079 9d0309c49d23e002410e1b0afd0aa33fc8e1c745
child 357081 62cd1c0a577044ee52ee8f90d8c6e6289c7240c8
push id6737
push userphilringnalda@gmail.com
push dateThu, 05 Jan 2017 04:24:27 +0000
treeherdermozilla-beta@f06afa54549b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1325501
milestone51.0
backs out4f14552f2b1acd5e93752b8d2fee02497392bece
10eb6b8c37f12d0d970774e3b5fae360fe57d856
b2636a0a25011e60e704701fddf3de03945c561a
e3127efa2f570ce95935c310d0919efd5453d272
Backed out 4 changesets (bug 1325501) for mass bustage CLOSED TREE Backed out changeset 4f14552f2b1a (bug 1325501) Backed out changeset 10eb6b8c37f1 (bug 1325501) Backed out changeset b2636a0a2501 (bug 1325501) Backed out changeset e3127efa2f57 (bug 1325501)
toolkit/components/telemetry/TelemetrySend.jsm
toolkit/modules/ServiceRequest.jsm
toolkit/modules/moz.build
toolkit/modules/tests/xpcshell/test_servicerequest_xhr.js
toolkit/modules/tests/xpcshell/xpcshell.ini
toolkit/mozapps/extensions/LightweightThemeManager.jsm
toolkit/mozapps/extensions/internal/AddonRepository.jsm
toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/extensions/test/browser/browser_metadataTimeout.js
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -17,17 +17,16 @@ this.EXPORTED_SYMBOLS = [
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
 Cu.import("resource://gre/modules/Log.jsm", this);
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/PromiseUtils.jsm");
-Cu.import("resource://gre/modules/ServiceRequest.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/TelemetryUtils.jsm", this);
 Cu.import("resource://gre/modules/Timer.jsm", this);
 
 XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
                                   "resource://gre/modules/AsyncShutdown.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStorage",
                                   "resource://gre/modules/TelemetryStorage.jsm");
@@ -891,17 +890,18 @@ var TelemetrySendImpl = {
 
     this._log.trace("_doPing - server: " + this._server + ", persisted: " + isPersisted +
                     ", id: " + id);
 
     const isNewPing = isV4PingFormat(ping);
     const version = isNewPing ? PING_FORMAT_VERSION : 1;
     const url = this._server + this._getSubmissionPath(ping) + "?v=" + version;
 
-    let request = new ServiceRequest();
+    let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
+                  .createInstance(Ci.nsIXMLHttpRequest);
     request.mozBackgroundRequest = true;
     request.timeout = PING_SUBMIT_TIMEOUT_MS;
 
     request.open("POST", url, true);
     request.overrideMimeType("text/plain");
     request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
     request.setRequestHeader("Date", Policy.now().toUTCString());
 
deleted file mode 100644
--- a/toolkit/modules/ServiceRequest.jsm
+++ /dev/null
@@ -1,49 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
-
-/**
-  * This module consolidates various code and data update requests, so flags
-  * can be set, Telemetry collected, etc. in a central place.
-  */
-
-Cu.import("resource://gre/modules/Log.jsm");
-Cu.importGlobalProperties(["XMLHttpRequest"]);
-
-this.EXPORTED_SYMBOLS = [ "ServiceRequest" ];
-
-const logger = Log.repository.getLogger("ServiceRequest");
-logger.level = Log.Level.Debug;
-logger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
-
-/**
-  * ServiceRequest is intended to be a drop-in replacement for current users
-  * of XMLHttpRequest.
-  *
-  * @param {Object} options - Options for underlying XHR, e.g. { mozAnon: bool }
-  */
-class ServiceRequest extends XMLHttpRequest {
-  constructor(options) {
-    super(options);
-  }
-  /**
-    * Opens an XMLHttpRequest, and sets the NSS "beConservative" flag.
-    * Requests are always async.
-    *
-    * @param {String} method - HTTP method to use, e.g. "GET".
-    * @param {String} url - URL to open.
-    * @param {Object} options - Additional options (reserved for future use).
-    */
-  open(method, url, options) {
-    super.open(method, url, true);
-
-    // Disable cutting edge features, like TLS 1.3, where middleboxes might brick us
-    if (super.channel instanceof Ci.nsIHttpChannelInternal) {
-      super.channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = true;
-    }
-  }
-}
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -74,17 +74,16 @@ EXTRA_JS_MODULES += [
     'RemoteSecurityUI.jsm',
     'RemoteWebProgress.jsm',
     'ResetProfile.jsm',
     'secondscreen/PresentationApp.jsm',
     'secondscreen/RokuApp.jsm',
     'secondscreen/SimpleServiceDiscovery.jsm',
     'SelectContentHelper.jsm',
     'SelectParentHelper.jsm',
-    'ServiceRequest.jsm',
     'Services.jsm',
     'SessionRecorder.jsm',
     'sessionstore/FormData.jsm',
     'sessionstore/ScrollPosition.jsm',
     'sessionstore/XPathGenerator.jsm',
     'ShortcutUtils.jsm',
     'Sntp.jsm',
     'SpatialNavigation.jsm',
deleted file mode 100644
--- a/toolkit/modules/tests/xpcshell/test_servicerequest_xhr.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-Cu.import("resource://gre/modules/ServiceRequest.jsm");
-
-add_task(function* test_tls_conservative() {
-  const request = new ServiceRequest();
-  request.open("GET", "http://example.com", false);
-
-  const sr_channel = request.channel.QueryInterface(Ci.nsIHttpChannelInternal);
-  ok(("beConservative" in sr_channel), "TLS setting is present in SR channel");
-  ok(sr_channel.beConservative, "TLS setting in request channel is set to conservative for SR");
-
-  const xhr = new XMLHttpRequest();
-  xhr.open("GET", "http://example.com", false);
-
-  const xhr_channel = xhr.channel.QueryInterface(Ci.nsIHttpChannelInternal);
-  ok(("beConservative" in xhr_channel), "TLS setting is present in XHR channel");
-  ok(!xhr_channel.beConservative, "TLS setting in request channel is not set to conservative for XHR");
-
-});
--- a/toolkit/modules/tests/xpcshell/xpcshell.ini
+++ b/toolkit/modules/tests/xpcshell/xpcshell.ini
@@ -67,9 +67,8 @@ skip-if = toolkit == 'android'
 skip-if = toolkit == 'android'
 [test_UpdateUtils_url.js]
 [test_UpdateUtils_updatechannel.js]
 [test_web_channel.js]
 [test_web_channel_broker.js]
 [test_ZipUtils.js]
 skip-if = toolkit == 'android'
 [test_Log_stackTrace.js]
-[test_servicerequest_xhr.js]
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -37,19 +37,16 @@ const PERSIST_ENABLED = true;
 const PERSIST_BYPASS_CACHE = false;
 const PERSIST_FILES = {
   headerURL: "lightweighttheme-header",
   footerURL: "lightweighttheme-footer"
 };
 
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeImageOptimizer",
   "resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ServiceRequest",
-  "resource://gre/modules/ServiceRequest.jsm");
-
 
 XPCOMUtils.defineLazyGetter(this, "_prefs", () => {
   return Services.prefs.getBranch("lightweightThemes.");
 });
 
 Object.defineProperty(this, "_maxUsedThemes", {
   get: function() {
     delete this._maxUsedThemes;
@@ -252,17 +249,18 @@ this.LightweightThemeManager = {
     } catch (e) {
       return;
     }
 
     var theme = this.currentTheme;
     if (!theme || !theme.updateURL)
       return;
 
-    var req = new ServiceRequest();
+    var req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
+                .createInstance(Ci.nsIXMLHttpRequest);
 
     req.mozBackgroundRequest = true;
     req.overrideMimeType("text/plain");
     req.open("GET", theme.updateURL, true);
     // Prevent the request from reading from the cache.
     req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     // Prevent the request from writing to the cache.
     req.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
@@ -19,18 +19,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DeferredSave",
                                   "resource://gre/modules/DeferredSave.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AddonRepository_SQLiteMigrator",
                                   "resource://gre/modules/addons/AddonRepository_SQLiteMigrator.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Promise",
                                   "resource://gre/modules/Promise.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ServiceRequest",
-                                   "resource://gre/modules/ServiceRequest.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 
 
 this.EXPORTED_SYMBOLS = [ "AddonRepository" ];
 
 const PREF_GETADDONS_CACHE_ENABLED       = "extensions.getAddons.cache.enabled";
 const PREF_GETADDONS_CACHE_TYPES         = "extensions.getAddons.cache.types";
@@ -96,16 +94,20 @@ const HTML_KEY_MAP = {
 // A map between XML keys to AddonSearchResult keys for integer values
 // that require no extra parsing from XML
 const INTEGER_KEY_MAP = {
   total_downloads:  "totalDownloads",
   weekly_downloads: "weeklyDownloads",
   daily_users:      "dailyUsers"
 };
 
+// Wrap the XHR factory so that tests can override with a mock
+var XHRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1",
+                                       "nsIXMLHttpRequest");
+
 function convertHTMLToPlainText(html) {
   if (!html)
     return html;
   var converter = Cc["@mozilla.org/widget/htmlformatconverter;1"].
                   createInstance(Ci.nsIFormatConverter);
 
   var input = Cc["@mozilla.org/supports-string;1"].
               createInstance(Ci.nsISupportsString);
@@ -1440,17 +1442,17 @@ this.AddonRepository = {
     }
 
     this._searching = true;
     this._callback = aCallback;
     this._maxResults = aMaxResults;
 
     logger.debug("Requesting " + aURI);
 
-    this._request = new ServiceRequest();
+    this._request = new XHRequest();
     this._request.mozBackgroundRequest = true;
     this._request.open("GET", aURI, true);
     this._request.overrideMimeType("text/xml");
     if (aTimeout) {
       this._request.timeout = aTimeout;
     }
 
     this._request.addEventListener("error", aEvent => this._reportFailure(), false);
--- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
@@ -30,19 +30,16 @@ Components.utils.import("resource://gre/
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
                                   "resource://gre/modules/AddonManager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AddonManagerPrivate",
                                   "resource://gre/modules/AddonManager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AddonRepository",
                                   "resource://gre/modules/addons/AddonRepository.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ServiceRequest",
-                                  "resource://gre/modules/ServiceRequest.jsm");
-
 
 // Shared code for suppressing bad cert dialogs.
 XPCOMUtils.defineLazyGetter(this, "CertUtils", function() {
   let certUtils = {};
   Components.utils.import("resource://gre/modules/CertUtils.jsm", certUtils);
   return certUtils;
 });
 
@@ -577,17 +574,18 @@ function UpdateParser(aId, aUpdateKey, a
   try {
     requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS);
   }
   catch (e) {
   }
 
   logger.debug("Requesting " + aUrl);
   try {
-    this.request = new ServiceRequest();
+    this.request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
+                   createInstance(Ci.nsIXMLHttpRequest);
     this.request.open("GET", this.url, true);
     this.request.channel.notificationCallbacks = new CertUtils.BadCertHandler(!requireBuiltIn);
     this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     // Prevent the request from writing to cache.
     this.request.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
     this.request.overrideMimeType("text/plain");
     this.request.setRequestHeader("Moz-XPI-Update", "1", true);
     this.request.timeout = TIMEOUT;
--- a/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm
+++ b/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm
@@ -3,29 +3,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 this.EXPORTED_SYMBOLS = [ "ProductAddonChecker" ];
 
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/CertUtils.jsm");
 /*globals checkCert, BadCertHandler*/
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/osfile.jsm");
 /*globals OS*/
 
-XPCOMUtils.defineLazyModuleGetter(this, "ServiceRequest",
-                                  "resource://gre/modules/ServiceRequest.jsm");
-
 var logger = Log.repository.getLogger("addons.productaddons");
 
 // This exists so that tests can override the XHR behaviour for downloading
 // the addon update XML file.
 var CreateXHR = function() {
   return Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
     createInstance(Ci.nsISupports);
 }
@@ -91,21 +87,16 @@ function downloadXML(url, allowNonBuiltI
       request = request.wrappedJSObject;
     }
     request.open("GET", url, true);
     request.channel.notificationCallbacks = new BadCertHandler(allowNonBuiltIn);
     // Prevent the request from reading from the cache.
     request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     // Prevent the request from writing to the cache.
     request.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
-    // Use conservative TLS settings. See bug 1325501.
-    // TODO move to ServiceRequest.
-    if (request.channel instanceof Ci.nsIHttpChannelInternal) {
-      request.channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = true;
-    }
     request.timeout = TIMEOUT_DELAY_MS;
 
     request.overrideMimeType("text/xml");
     // The Cache-Control header is only interpreted by proxies and the
     // final destination. It does not help if a resource is already
     // cached locally.
     request.setRequestHeader("Cache-Control", "no-cache");
     // HTTP/1.0 servers might not implement Cache-Control and
@@ -192,17 +183,18 @@ function parseXML(document) {
  *
  * @param  url
  *         The url to download from.
  * @return a promise that resolves to the path of a temporary file or rejects
  *         with a JS exception in case of error.
  */
 function downloadFile(url) {
   return new Promise((resolve, reject) => {
-    let xhr = new XMLHttpRequest();
+    let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
+                  createInstance(Ci.nsISupports);
     xhr.onload = function(response) {
       logger.info("downloadXHR File download. status=" + xhr.status);
       if (xhr.status != 200 && xhr.status != 206) {
         reject(Components.Exception("File download failed", xhr.status));
         return;
       }
       Task.spawn(function* () {
         let f = yield OS.File.openUnique(OS.Path.join(OS.Constants.Path.tmpDir, "tmpaddon"));
@@ -224,21 +216,16 @@ function downloadFile(url) {
       reject(ex);
     };
     xhr.addEventListener("error", fail);
     xhr.addEventListener("abort", fail);
 
     xhr.responseType = "arraybuffer";
     try {
       xhr.open("GET", url);
-      // Use conservative TLS settings. See bug 1325501.
-      // TODO move to ServiceRequest.
-      if (xhr.channel instanceof Ci.nsIHttpChannelInternal) {
-        xhr.channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = true;
-      }
       xhr.send(null);
     } catch (ex) {
       reject(ex);
     }
   });
 }
 
 /**
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -24,18 +24,16 @@ try {
 }
 
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
                                   "resource://gre/modules/UpdateUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ServiceRequest",
-                                  "resource://gre/modules/ServiceRequest.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DOMApplicationRegistry",
                                   "resource://gre/modules/Webapps.jsm");
 
 const TOOLKIT_ID                      = "toolkit@mozilla.org";
 const KEY_PROFILEDIR                  = "ProfD";
 const KEY_APPDIR                      = "XCurProcD";
@@ -609,17 +607,18 @@ Blocklist.prototype = {
     }
     catch (e) {
       LOG("Blocklist::notify: There was an error creating the blocklist URI\r\n" +
           "for: " + dsURI + ", error: " + e);
       return;
     }
 
     LOG("Blocklist::notify: Requesting " + uri.spec);
-    let request = new ServiceRequest();
+    var request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
+                  createInstance(Ci.nsIXMLHttpRequest);
     request.open("GET", uri.spec, true);
     request.channel.notificationCallbacks = new gCertUtils.BadCertHandler();
     request.overrideMimeType("text/xml");
     request.setRequestHeader("Cache-Control", "no-cache");
     request.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
 
     request.addEventListener("error", event => this.onXMLError(event), false);
     request.addEventListener("load", event => this.onXMLLoad(event), false);
--- a/toolkit/mozapps/extensions/test/browser/browser_metadataTimeout.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_metadataTimeout.js
@@ -14,18 +14,18 @@ const PREF_METADATA_LASTUPDATE        = 
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 var repo = {};
 var ARContext = Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", repo);
 
 // Mock out the XMLHttpRequest factory for AddonRepository so
 // we can reply with a timeout
 var pXHRStarted = Promise.defer();
-var oldXHRConstructor = ARContext.ServiceRequest;
-ARContext.ServiceRequest = function() {
+var oldXHRConstructor = ARContext.XHRequest;
+ARContext.XHRequest = function() {
   this._handlers = new Map();
   this.mozBackgroundRequest = false;
   this.timeout = undefined;
   this.open = function(aMethod, aURI, aAsync) {
       this.method = aMethod;
       this.uri = aURI;
       this.async = aAsync;
       info("Opened XHR for " + aMethod + " " + aURI);
@@ -103,12 +103,12 @@ add_task(function* amo_ping_timeout() {
 
   let xhr = yield pXHRStarted.promise;
   is(xhr.timeout, 30000, "XHR request should have 30 second timeout");
   ok(xhr._handlers.has("timeout"), "Timeout handler set on XHR");
   // call back the timeout handler
   xhr._handlers.get("timeout")();
 
   // Put the old XHR constructor back
-  ARContext.ServiceRequest = oldXHRConstructor;
+  ARContext.XHRequest = oldXHRConstructor;
   // The window should close without further interaction
   yield promise_window_close(compatWindow);
 });