webapprt/test/chrome/browser_window-open-self.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial