Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
3 let HandlerService = {
4 classID: Components.ID("{b4ed9fab-fd39-435a-8e3e-edc3e689e72e}"),
6 QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory,
7 Ci.nsIExternalProtocolService]),
9 createInstance: function(aOuter, aIID) {
10 if (aOuter) {
11 throw Cr.NS_ERROR_NO_AGGREGATION;
12 }
14 return this.QueryInterface(aIID);
15 },
17 init: function() {
18 Components.manager.nsIComponentRegistrar.registerFactory(this.classID,
19 "Test Protocol Handler Service",
20 "@mozilla.org/uriloader/external-protocol-service;1",
21 this);
22 },
24 getProtocolHandlerInfo: function(aProtocolScheme) {
25 let handlerInfoObj = {
26 launchWithURI: function(aURI) {
27 is(aURI.spec,
28 "http://test/webapprtChrome/webapprt/test/chrome/sample.html",
29 "The app tried to open the link in the default browser");
31 finish();
32 }
33 };
35 return handlerInfoObj;
36 }
37 };
39 HandlerService.init();
41 function test() {
42 waitForExplicitFinish();
44 let progressListener = {
45 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
46 Ci.nsISupportsWeakReference]),
47 onLocationChange: function(progress, request, location, flags) {
48 ok(false, "Location changed");
49 finish();
50 }
51 };
53 let winObserver = function(win, topic) {
54 if (topic == "domwindowopened") {
55 win.addEventListener("load", function onLoadWindow() {
56 win.removeEventListener("load", onLoadWindow, false);
58 if (win.location == "chrome://webapprt/content/webapp.xul") {
59 ok(false, "New app window opened");
60 finish();
61 }
62 }, false);
63 }
64 }
66 loadWebapp("window-open-blank.webapp", undefined, function() {
67 gAppBrowser.addProgressListener(progressListener,
68 Ci.nsIWebProgress.NOTIFY_LOCATION);
69 });
71 registerCleanupFunction(function() {
72 Services.ww.unregisterNotification(winObserver);
73 gAppBrowser.removeProgressListener(progressListener);
74 });
75 }