From 20d8fc6912e5294cf058779655170dad4e66b0fb Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Tue, 22 Jun 2010 19:11:20 -0700 Subject: [PATCH] Bug 573740 - Register resource://services-sync before xpcshell tests get run [r=mconnor] Add the alias to resource://services-sync when loading the component instead of waiting for app-startup, which doesn't fire for xpcshell tests. --- services/sync/Weave.js | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/services/sync/Weave.js b/services/sync/Weave.js index 9e8436e6bba..b5bbb03b31c 100644 --- a/services/sync/Weave.js +++ b/services/sync/Weave.js @@ -56,7 +56,6 @@ WeaveService.prototype = { let os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); os.addObserver(this, "final-ui-startup", true); - this.addResourceAlias(); break; case "final-ui-startup": @@ -69,26 +68,6 @@ WeaveService.prototype = { }, 10000, Ci.nsITimer.TYPE_ONE_SHOT); break; } - }, - - addResourceAlias: function() { - let ioService = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService); - let resProt = ioService.getProtocolHandler("resource") - .QueryInterface(Ci.nsIResProtocolHandler); - - - // Only create alias if resource://services-sync doesn't already exist. - if (resProt.hasSubstitution("services-sync")) - return; - - let uri = ioService.newURI("resource://gre/modules/services-sync", - null, null); - let file = uri.QueryInterface(Ci.nsIFileURL) - .file.QueryInterface(Ci.nsILocalFile); - - let aliasURI = ioService.newFileURI(file); - resProt.setSubstitution("services-sync", aliasURI); } }; @@ -156,3 +135,19 @@ function NSGetModule(compMgr, fileSpec) { ]); } +(function addResourceAlias() { + let ioService = Cc["@mozilla.org/network/io-service;1"]. + getService(Ci.nsIIOService); + let resProt = ioService.getProtocolHandler("resource"). + QueryInterface(Ci.nsIResProtocolHandler); + + // Only create alias if resource://services-sync doesn't already exist. + if (resProt.hasSubstitution("services-sync")) + return; + + let uri = ioService.newURI("resource://gre/modules/services-sync", null, null); + let file = uri.QueryInterface(Ci.nsIFileURL).file.QueryInterface(Ci.nsILocalFile); + + let aliasURI = ioService.newFileURI(file); + resProt.setSubstitution("services-sync", aliasURI); +})();