Bug 1484466: Part 3a - Update remaining XPCOMUtils.generateQI callers to use ChromeUtils. r=mccr8
authorKris Maglione <maglione.k@gmail.com>
Sat, 18 Aug 2018 12:44:57 -0700
changeset 487608 db23f8b137c534451c0aee11f1ee6538d551b4ce
parent 487607 432da59e0c1b73548aa10cc0acaf8c6af04503b7
child 487609 2498075cf65ac9a17760e7059d69ef4c13769b51
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1484466
milestone63.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 1484466: Part 3a - Update remaining XPCOMUtils.generateQI callers to use ChromeUtils. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D3709
browser/base/content/test/chrome/test_aboutRestartRequired.xul
dom/tests/browser/browser_ConsoleAPITests.js
js/xpconnect/loader/XPCOMUtils.jsm
js/xpconnect/tests/unit/test_nuke_sandbox.js
mobile/android/tests/browser/robocop/testAndroidCastDeviceProvider.js
netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
storage/test/unit/test_vacuum.js
toolkit/components/places/tests/unit/test_telemetry.js
uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
--- a/browser/base/content/test/chrome/test_aboutRestartRequired.xul
+++ b/browser/base/content/test/chrome/test_aboutRestartRequired.xul
@@ -8,17 +8,16 @@
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <iframe type="content" id="frame1"/>
   <iframe type="content" id="frame2" onload="doTest()"/>
   <script type="application/javascript"><![CDATA[
     ChromeUtils.import("resource://gre/modules/Services.jsm");
-    ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
     SimpleTest.waitForExplicitFinish();
 
     // Load error pages do not fire "load" events, so let's use a progressListener.
     function waitForErrorPage(frame) {
       return new Promise(resolve => {
         let progressListener = {
           onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
@@ -27,18 +26,18 @@
                             .getInterface(Ci.nsIWebProgress)
                             .removeProgressListener(progressListener,
                                                     Ci.nsIWebProgress.NOTIFY_LOCATION);
 
               resolve();
             }
           },
 
-          QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
-                                                 Ci.nsISupportsWeakReference])
+          QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
+                                                  Ci.nsISupportsWeakReference])
         };
 
         frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                       .getInterface(Ci.nsIWebProgress)
                       .addProgressListener(progressListener,
                                            Ci.nsIWebProgress.NOTIFY_LOCATION);
       });
     }
--- a/dom/tests/browser/browser_ConsoleAPITests.js
+++ b/dom/tests/browser/browser_ConsoleAPITests.js
@@ -47,17 +47,17 @@ function spawnWithObserver(browser, obse
     // before exiting the test
     "  let resolve = () => {",
     "    Services.obs.removeObserver(ConsoleObserver, 'console-api-log-event');",
     "    _resolve();",
     "  };",
     // This is the observer itself, it calls the passed-in function whenever
     // it encounters an event
     "  let ConsoleObserver = {",
-    "    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),",
+    "    QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),",
     "    observe: function(aSubject, aTopic, aData) {",
     "      try {",
     "        (" + observerFunc.toString() + ")(aSubject.wrappedJSObject);",
     "      } catch (ex) {",
     "        ok(false, 'Exception thrown in observe: ' + ex);",
     "      }",
     "    }",
     "  };",
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -23,17 +23,17 @@
  *    classID:          Components.ID("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"),
  *
  *    // [optional] custom factory (an object implementing nsIFactory). If not
  *    // provided, the default factory is used, which returns
  *    // |(new MyComponent()).QueryInterface(iid)| in its createInstance().
  *    _xpcom_factory: { ... },
  *
  *    // QueryInterface implementation, e.g. using the generateQI helper
- *    QueryInterface: XPCOMUtils.generateQI(
+ *    QueryInterface: ChromeUtils.generateQI(
  *      [Components.interfaces.nsIObserver,
  *       Components.interfaces.nsIMyInterface,
  *       "nsIFoo",
  *       "nsIBar" ]),
  *
  *    // The following properties were used prior to Mozilla 2, but are no
  *    // longer supported. They may still be included for compatibility with
  *    // prior versions of XPCOMUtils. In Mozilla 2, this information is
--- a/js/xpconnect/tests/unit/test_nuke_sandbox.js
+++ b/js/xpconnect/tests/unit/test_nuke_sandbox.js
@@ -6,25 +6,23 @@
 
 const global = this;
 
 function run_test()
 {
   var ifacePointer = Cc["@mozilla.org/supports-interface-pointer;1"]
       .createInstance(Ci.nsISupportsInterfacePointer);
 
-  var sb = Cu.Sandbox(global);
+  var sb = Cu.Sandbox(global, {wantGlobalProperties: ["ChromeUtils"]});
   sb.prop = "prop"
   sb.ifacePointer = ifacePointer
 
   var refToObjFromSb = Cu.evalInSandbox(`
-    Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
     ifacePointer.data = {
-      QueryInterface: XPCOMUtils.generateQI([]),
+      QueryInterface: ChromeUtils.generateQI([]),
       wrappedJSObject: {foo: "bar"},
     };
 
     var a = {prop2:'prop2'};
     a
   `, sb);
 
   equal(ifacePointer.data.wrappedJSObject.foo, "bar",
--- a/mobile/android/tests/browser/robocop/testAndroidCastDeviceProvider.js
+++ b/mobile/android/tests/browser/robocop/testAndroidCastDeviceProvider.js
@@ -8,16 +8,18 @@
 
 "use strict";
 
 /* eslint-disable mozilla/use-chromeutils-import */
 
 Cu.import("resource://gre/modules/Messaging.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
+const {ChromeUtils} = Cu.getGlobalForObject(XPCOMUtils);
+
 // event name
 const TOPIC_ANDROID_CAST_DEVICE_ADDED   = "AndroidCastDevice:Added";
 const TOPIC_ANDROID_CAST_DEVICE_REMOVED = "AndroidCastDevice:Removed";
 const TOPIC_ANDROID_CAST_DEVICE_START   = "AndroidCastDevice:Start";
 const TOPIC_PRESENTATION_VIEW_READY     = "presentation-view-ready";
 
 // contract ID
 const ANDROID_BRIDGE_CONTRACT_ID  = "@mozilla.org/android/bridge;1";
@@ -46,17 +48,17 @@ function TestDescription(aType, aTcpAddr
       .createInstance(Ci.nsISupportsCString);
     wrapper.data = address;
     this.tcpAddress.appendElement(wrapper);
   }
   this.tcpPort = aTcpPort;
 }
 
 TestDescription.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationChannelDescription]),
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationChannelDescription]),
 };
 
 function TestControlChannelListener(aRole) {
   log("TestControlChannelListener of " + aRole + " is created.");
   this._role = aRole;
   this.isNotifyConnectedCalled = new Promise((aResolve) => {
     this._isNotifyConnectedCalledResolve = aResolve;
   });
@@ -86,17 +88,17 @@ TestControlChannelListener.prototype = {
   isOnAnswerCalled: null,
   isOnIceCandidateCalled: null,
   isNotifyDisconnectedCalled: null,
   notifyConnected: function() { this._isNotifyConnectedCalledResolve(); },
   notifyDisconnected: function(aReason) { log(this._role + " call disconnect"); this._isNotifyDisconnectedCalledResolve(); },
   onOffer: function(aOffer) { this._isOnOfferCalledResolve(); },
   onAnswer: function(aAnswer) { this._isOnAnswerCalledResolve(); },
   onIceCandidate: function(aCandidate) { this._isOnIceCandidateCalledResolve(); },
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlChannelListener])
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationControlChannelListener])
 };
 
 function deviceManagement() {
   do_test_pending();
 
   let provider = Cc[DEVICE_PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
   let listener = {
     devices: {},
@@ -113,18 +115,18 @@ function deviceManagement() {
     updateDevice: function(aDevice) {
       this.devices[aDevice.id] = aDevice;
       this._isUpdateDeviceCalledResolve();
     },
     removeDevice: function(aDevice) {
       delete this.devices[aDevice.id];
       this._isRemoveDeviceCalledResolve();
     },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationDeviceListener,
-                                           Ci.nsISupportsWeakReference]),
+    QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
+                                            Ci.nsISupportsWeakReference]),
     count: function() {
       let cnt = 0;
       for (let key in this.devices) {
         if (this.devices.hasOwnProperty(key)) {
           ++cnt;
         }
       }
       return cnt;
@@ -199,18 +201,18 @@ function presentationLaunchAndTerminate(
   let receiverControlChannelListener = new TestControlChannelListener("receiver");
 
   let provider = Cc[DEVICE_PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
   let listener = {
     devices: {},
     addDevice: function(aDevice) { this.devices[aDevice.id] = aDevice; },
     updateDevice: function(aDevice) { this.devices[aDevice.id] = aDevice; },
     removeDevice: function(aDevice) { delete this.devices[aDevice.id]; },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationDeviceListener,
-                                           Ci.nsISupportsWeakReference]),
+    QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
+                                            Ci.nsISupportsWeakReference]),
     onSessionRequest: function(aDeviceId, aUrl, aPresentationId, aControlChannel) {
       receiverControlChannel = aControlChannel;
       receiverControlChannel.listener = receiverControlChannelListener;
     },
     onTerminateRequest: function(aDevice, aPresentationId, aControlChannel, aIsFromReceiver) {
       receiverControlChannel = aControlChannel;
       receiverControlChannel.listener = receiverControlChannelListener;
     },
--- a/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
+++ b/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
@@ -70,17 +70,17 @@ function CustomChannel(aURI, aLoadInfo) 
   this._uploadStream = null;
 
   var interfaces = [Ci.nsIRequest, Ci.nsIChannel];
   if (this.uri.spec == POST_ACTION_URI) {
     interfaces.push(Ci.nsIFormPOSTActionChannel);
   } else if (this.uri.spec == UPLOAD_ACTION_URI) {
     interfaces.push(Ci.nsIUploadChannel);
   }
-  this.QueryInterface = XPCOMUtils.generateQI(interfaces);
+  this.QueryInterface = ChromeUtils.generateQI(interfaces);
 }
 CustomChannel.prototype = {
   /** nsIUploadChannel */
   get uploadStream() {
     return this._uploadStream;
   },
   set uploadStream(val) {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
--- a/storage/test/unit/test_vacuum.js
+++ b/storage/test/unit/test_vacuum.js
@@ -246,17 +246,17 @@ const TESTS = [
           }
         }
         finally {
           stmt.finalize();
         }
 
         run_next_test();
       },
-      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+      QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver])
     }
     Services.obs.addObserver(vacuumObserver, "test-end-vacuum", false);
 
     synthesize_idle_daily();
   },
   */
 
   function test_memory_database_crash() {
@@ -293,17 +293,17 @@ const TESTS = [
     // Wait for VACUUM end.
     let vacuumObserver = {
       observe: function VO_observe(aSubject, aTopic, aData) {
         Services.obs.removeObserver(vacuumObserver, "test-end-vacuum");
         print("Check WAL restoration failed.");
         do_check_false(aData);
         run_next_test();
       },
-      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+      QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver])
     }
     Services.obs.addObserver(vacuumObserver, "test-end-vacuum", false);
 
     synthesize_idle_daily();
   },
   */
 ];
 
--- a/toolkit/components/places/tests/unit/test_telemetry.js
+++ b/toolkit/components/places/tests/unit/test_telemetry.js
@@ -141,17 +141,17 @@ add_task(async function test_execute() {
     disableAutoComplete: false,
     completeDefaultIndex: false,
     get popup() { return this; },
     onSearchBegin: function() {},
     onSearchComplete: function() {},
     setSelectedIndex: function() {},
     get searchCount() { return this.searches.length; },
     getSearchAt: function(aIndex) { return this.searches[aIndex]; },
-    QueryInterface: XPCOMUtils.generateQI([
+    QueryInterface: ChromeUtils.generateQI([
       Ci.nsIAutoCompleteInput,
       Ci.nsIAutoCompletePopup,
     ])
   };
   let controller = Cc["@mozilla.org/autocomplete/controller;1"].
                    getService(Ci.nsIAutoCompleteController);
   controller.input = new AutoCompleteInput(["unifiedcomplete"]);
   controller.startSearch("moz");
--- a/uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
+++ b/uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
@@ -7,17 +7,17 @@
  * Test for bug 484579 <https://bugzilla.mozilla.org/show_bug.cgi?id=484579>:
  * nsIMIMEService.getTypeFromExtension may fail unexpectedly on Windows when
  * "Content Type" is empty in the registry.
  */
 function run_test() {
   // --- Preliminary platform check ---
 
   // If this test is not running on the Windows platform, stop now, before
-  // calling XPCOMUtils.generateQI during the MockWindowsRegKey declaration.
+  // calling ChromeUtils.generateQI during the MockWindowsRegKey declaration.
   if (mozinfo.os != "win")
     return;
 
   // --- Modified nsIWindowsRegKey implementation ---
 
   /**
    * Constructs a new mock registry key by wrapping the provided object.
    *