|
1 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
2 Cu.import("resource://webapprt/modules/WebappRT.jsm"); |
|
3 let { DOMApplicationRegistry } = |
|
4 Cu.import("resource://gre/modules/Webapps.jsm", {}); |
|
5 |
|
6 function test() { |
|
7 waitForExplicitFinish(); |
|
8 |
|
9 let appID = Ci.nsIScriptSecurityManager.NO_APP_ID; |
|
10 |
|
11 let progressListener = { |
|
12 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, |
|
13 Ci.nsISupportsWeakReference]), |
|
14 onLocationChange: function(progress, request, location, flags) { |
|
15 gAppBrowser.addEventListener("load", function onLoad() { |
|
16 gAppBrowser.removeEventListener("load", onLoad, true); |
|
17 |
|
18 is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL), |
|
19 appID, |
|
20 "Principal app ID hasn't changed"); |
|
21 |
|
22 finish(); |
|
23 }, true); |
|
24 } |
|
25 }; |
|
26 |
|
27 let winObserver = function(win, topic) { |
|
28 if (topic == "domwindowopened") { |
|
29 win.addEventListener("load", function onLoadWindow() { |
|
30 win.removeEventListener("load", onLoadWindow, false); |
|
31 |
|
32 if (win.location == "chrome://webapprt/content/webapp.xul") { |
|
33 ok(false, "New app window opened"); |
|
34 finish(); |
|
35 } |
|
36 }, false); |
|
37 } |
|
38 } |
|
39 |
|
40 loadWebapp("window-open-self.webapp", undefined, function() { |
|
41 appID = gAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId; |
|
42 |
|
43 is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL), |
|
44 appID, |
|
45 "Principal app ID correct"); |
|
46 |
|
47 gAppBrowser.addProgressListener(progressListener, |
|
48 Ci.nsIWebProgress.NOTIFY_LOCATION); |
|
49 }); |
|
50 |
|
51 registerCleanupFunction(function() { |
|
52 Services.ww.unregisterNotification(winObserver); |
|
53 gAppBrowser.removeProgressListener(progressListener); |
|
54 }); |
|
55 } |