From e83a3a1a7c776b1c749fc4323fd7431dc0cd1a8e Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 3 Mar 2015 19:47:00 -0500 Subject: [PATCH] Bug 1139254 - Use MockRegistrar in chrome. r=gps --- chrome/test/unit/test_bug519468.js | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/chrome/test/unit/test_bug519468.js b/chrome/test/unit/test_bug519468.js index 2e5071641f5..a318bda5086 100644 --- a/chrome/test/unit/test_bug519468.js +++ b/chrome/test/unit/test_bug519468.js @@ -7,28 +7,14 @@ var MANIFESTS = [ do_get_file("data/test_bug519468.manifest") ]; +Components.utils.import("resource://testing-common/MockRegistrar.jsm"); // Stub in the locale service so we can control what gets returned as the OS locale setting Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); let stubOSLocale = null; -stubID = Components.ID("9d09d686-d913-414c-a1e6-4be8652d7d93"); -localeContractID = "@mozilla.org/intl/nslocaleservice;1"; - StubLocaleService = { - classDescription: "Stub version of Locale service for testing", - classID: stubID, - contractID: localeContractID, - QueryInterface: XPCOMUtils.generateQI([Ci.nsILocaleService, Ci.nsISupports, Ci.nsIFactory]), - - createInstance: function (outer, iid) { - if (outer) - throw Components.results.NS_ERROR_NO_AGGREGATION; - return this.QueryInterface(iid); - }, - lockFactory: function (lock) { - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; - }, + QueryInterface: XPCOMUtils.generateQI([Ci.nsILocaleService, Ci.nsISupports]), getLocaleComponentForUserAgent: function SLS_getLocaleComponentForUserAgent() { @@ -36,14 +22,7 @@ StubLocaleService = { } } -let registrar = Components.manager.nsIComponentRegistrar; -// Save original factory. -let localeCID = registrar.contractIDToCID(localeContractID) -let originalFactory = - Components.manager.getClassObject(Components.classes[localeContractID], - Components.interfaces.nsIFactory); - -registrar.registerFactory(stubID, "Unit test Locale Service", localeContractID, StubLocaleService); +MockRegistrar.register("@mozilla.org/intl/nslocaleservice;1", StubLocaleService); // Now fire up the test do_test_pending()