1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/webapprt/test/chrome/browser_window-open-self.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.5 +Cu.import("resource://webapprt/modules/WebappRT.jsm"); 1.6 +let { DOMApplicationRegistry } = 1.7 + Cu.import("resource://gre/modules/Webapps.jsm", {}); 1.8 + 1.9 +function test() { 1.10 + waitForExplicitFinish(); 1.11 + 1.12 + let appID = Ci.nsIScriptSecurityManager.NO_APP_ID; 1.13 + 1.14 + let progressListener = { 1.15 + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, 1.16 + Ci.nsISupportsWeakReference]), 1.17 + onLocationChange: function(progress, request, location, flags) { 1.18 + gAppBrowser.addEventListener("load", function onLoad() { 1.19 + gAppBrowser.removeEventListener("load", onLoad, true); 1.20 + 1.21 + is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL), 1.22 + appID, 1.23 + "Principal app ID hasn't changed"); 1.24 + 1.25 + finish(); 1.26 + }, true); 1.27 + } 1.28 + }; 1.29 + 1.30 + let winObserver = function(win, topic) { 1.31 + if (topic == "domwindowopened") { 1.32 + win.addEventListener("load", function onLoadWindow() { 1.33 + win.removeEventListener("load", onLoadWindow, false); 1.34 + 1.35 + if (win.location == "chrome://webapprt/content/webapp.xul") { 1.36 + ok(false, "New app window opened"); 1.37 + finish(); 1.38 + } 1.39 + }, false); 1.40 + } 1.41 + } 1.42 + 1.43 + loadWebapp("window-open-self.webapp", undefined, function() { 1.44 + appID = gAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId; 1.45 + 1.46 + is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL), 1.47 + appID, 1.48 + "Principal app ID correct"); 1.49 + 1.50 + gAppBrowser.addProgressListener(progressListener, 1.51 + Ci.nsIWebProgress.NOTIFY_LOCATION); 1.52 + }); 1.53 + 1.54 + registerCleanupFunction(function() { 1.55 + Services.ww.unregisterNotification(winObserver); 1.56 + gAppBrowser.removeProgressListener(progressListener); 1.57 + }); 1.58 +}