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: ok(false, "Content redirected") 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: let winAppBrowser = win.document.getElementById("content"); michael@0: winAppBrowser.addEventListener("load", function onLoadBrowser() { michael@0: winAppBrowser.removeEventListener("load", onLoadBrowser, true); michael@0: michael@0: is(winAppBrowser.getAttribute("src"), michael@0: "http://test/webapprtChrome/webapprt/test/chrome/sample.html", michael@0: "New window browser has correct src"); michael@0: michael@0: is(winAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId, michael@0: appID, michael@0: "New window principal app ID correct"); michael@0: michael@0: win.close(); michael@0: michael@0: finish(); michael@0: }, true); michael@0: } michael@0: }, false); michael@0: } michael@0: } michael@0: michael@0: Services.ww.registerNotification(winObserver); michael@0: michael@0: loadWebapp("window-open.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: }