michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://webapprt/modules/WebappRT.jsm"); michael@0: let { DOMApplicationRegistry } = michael@0: Cu.import("resource://gre/modules/Webapps.jsm", {}); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let appID = Ci.nsIScriptSecurityManager.NO_APP_ID; 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: gAppBrowser.addEventListener("load", function onLoad() { michael@0: gAppBrowser.removeEventListener("load", onLoad, true); michael@0: michael@0: is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL), michael@0: appID, michael@0: "Principal app ID hasn't changed"); michael@0: michael@0: finish(); michael@0: }, true); 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-self.webapp", undefined, function() { michael@0: appID = gAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId; michael@0: michael@0: is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL), michael@0: appID, michael@0: "Principal app ID correct"); michael@0: 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: }