|
1 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
2 |
|
3 let HandlerService = { |
|
4 classID: Components.ID("{b4ed9fab-fd39-435a-8e3e-edc3e689e72e}"), |
|
5 |
|
6 QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory, |
|
7 Ci.nsIExternalProtocolService]), |
|
8 |
|
9 createInstance: function(aOuter, aIID) { |
|
10 if (aOuter) { |
|
11 throw Cr.NS_ERROR_NO_AGGREGATION; |
|
12 } |
|
13 |
|
14 return this.QueryInterface(aIID); |
|
15 }, |
|
16 |
|
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 }, |
|
23 |
|
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"); |
|
30 |
|
31 finish(); |
|
32 } |
|
33 }; |
|
34 |
|
35 return handlerInfoObj; |
|
36 } |
|
37 }; |
|
38 |
|
39 HandlerService.init(); |
|
40 |
|
41 function test() { |
|
42 waitForExplicitFinish(); |
|
43 |
|
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 }; |
|
52 |
|
53 let winObserver = function(win, topic) { |
|
54 if (topic == "domwindowopened") { |
|
55 win.addEventListener("load", function onLoadWindow() { |
|
56 win.removeEventListener("load", onLoadWindow, false); |
|
57 |
|
58 if (win.location == "chrome://webapprt/content/webapp.xul") { |
|
59 ok(false, "New app window opened"); |
|
60 finish(); |
|
61 } |
|
62 }, false); |
|
63 } |
|
64 } |
|
65 |
|
66 loadWebapp("window-open-blank.webapp", undefined, function() { |
|
67 gAppBrowser.addProgressListener(progressListener, |
|
68 Ci.nsIWebProgress.NOTIFY_LOCATION); |
|
69 }); |
|
70 |
|
71 registerCleanupFunction(function() { |
|
72 Services.ww.unregisterNotification(winObserver); |
|
73 gAppBrowser.removeProgressListener(progressListener); |
|
74 }); |
|
75 } |