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.

     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", {});
     6 function test() {
     7   waitForExplicitFinish();
     9   let appID = Ci.nsIScriptSecurityManager.NO_APP_ID;
    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);
    18         is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL),
    19            appID,
    20            "Principal app ID hasn't changed");
    22         finish();
    23       }, true);
    24     }
    25   };
    27   let winObserver = function(win, topic) {
    28     if (topic == "domwindowopened") {
    29       win.addEventListener("load", function onLoadWindow() {
    30         win.removeEventListener("load", onLoadWindow, false);
    32         if (win.location == "chrome://webapprt/content/webapp.xul") {
    33           ok(false, "New app window opened");
    34           finish();
    35         }
    36       }, false);
    37     }
    38   }
    40   loadWebapp("window-open-self.webapp", undefined, function() {
    41     appID = gAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId;
    43     is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL),
    44        appID,
    45        "Principal app ID correct");
    47     gAppBrowser.addProgressListener(progressListener,
    48                                     Ci.nsIWebProgress.NOTIFY_LOCATION);
    49   });
    51   registerCleanupFunction(function() {
    52     Services.ww.unregisterNotification(winObserver);
    53     gAppBrowser.removeProgressListener(progressListener);
    54   });
    55 }

mercurial