michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: let HandlerService = { michael@0: classID: Components.ID("{b4ed9fab-fd39-435a-8e3e-edc3e689e72e}"), michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory, michael@0: Ci.nsIExternalProtocolService]), michael@0: michael@0: createInstance: function(aOuter, aIID) { michael@0: if (aOuter) { michael@0: throw Cr.NS_ERROR_NO_AGGREGATION; michael@0: } michael@0: michael@0: return this.QueryInterface(aIID); michael@0: }, michael@0: michael@0: init: function() { michael@0: Components.manager.nsIComponentRegistrar.registerFactory(this.classID, michael@0: "Test Protocol Handler Service", michael@0: "@mozilla.org/uriloader/external-protocol-service;1", michael@0: this); michael@0: }, michael@0: michael@0: getProtocolHandlerInfo: function(aProtocolScheme) { michael@0: let handlerInfoObj = { michael@0: launchWithURI: function(aURI) { michael@0: is(aURI.spec, michael@0: "http://test/webapprtChrome/webapprt/test/chrome/sample.html", michael@0: "The app tried to open the link in the default browser"); michael@0: michael@0: finish(); michael@0: } michael@0: }; michael@0: michael@0: return handlerInfoObj; michael@0: } michael@0: }; michael@0: michael@0: HandlerService.init(); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let progressListener = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, michael@0: Ci.nsISupportsWeakReference]), michael@0: onLocationChange: function(progress, request, location, flags) { michael@0: ok(false, "Location changed"); michael@0: finish(); michael@0: } michael@0: }; michael@0: michael@0: let winObserver = function(win, topic) { michael@0: if (topic == "domwindowopened") { michael@0: win.addEventListener("load", function onLoadWindow() { michael@0: win.removeEventListener("load", onLoadWindow, false); michael@0: michael@0: if (win.location == "chrome://webapprt/content/webapp.xul") { michael@0: ok(false, "New app window opened"); michael@0: finish(); michael@0: } michael@0: }, false); michael@0: } michael@0: } michael@0: michael@0: loadWebapp("window-open-blank.webapp", undefined, function() { michael@0: gAppBrowser.addProgressListener(progressListener, michael@0: Ci.nsIWebProgress.NOTIFY_LOCATION); michael@0: }); michael@0: michael@0: registerCleanupFunction(function() { michael@0: Services.ww.unregisterNotification(winObserver); michael@0: gAppBrowser.removeProgressListener(progressListener); michael@0: }); michael@0: }