dom/tests/mochitest/webapps/test_bug_771294.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <?xml version="1.0"?>
     3 <!-- Any copyright is dedicated to the Public Domain.
     4    - http://creativecommons.org/publicdomain/zero/1.0/ -->
     6 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     7 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    10         title="Mozilla Bug 771294">
    11   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    12   <script type="application/javascript" src="head.js"/>
    13   <!-- test results are displayed in the html:body -->
    14   <body xmlns="http://www.w3.org/1999/xhtml">
    15   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771294"
    16      target="_blank">Mozilla Bug 771294</a>
    17   </body>
    19 <script>
    20 const Ci = Components.interfaces;
    21 const Cu = Components.utils;
    23 SimpleTest.waitForExplicitFinish();
    25 SpecialPowers.setAllAppsLaunchable(true);
    27 Cu.import("resource://gre/modules/Services.jsm");
    28 Cu.import("resource://gre/modules/PopupNotifications.jsm");
    30 let blocked = true;
    32 function blockedListener() {
    33   blocked = false;
    34 }
    36 let panel = window.top.QueryInterface(Ci.nsIInterfaceRequestor)
    37                   .getInterface(Ci.nsIWebNavigation)
    38                   .QueryInterface(Ci.nsIDocShell)
    39                   .chromeEventHandler.ownerDocument.defaultView
    40                   .PopupNotifications.panel;
    42 panel.addEventListener("popupshowing", blockedListener, false);
    44 Services.obs.addObserver(
    45   function observeInstalling() {
    46     Services.obs.removeObserver(observeInstalling, "webapps-ask-install");
    47     // Spin the event loop before running the test to give the registry time
    48     // to process the install request and (hopefully not) show the doorhanger.
    49     setTimeout(function verify() {
    50       ok(blocked, "Install panel was blocked after immediate redirect");
    51       panel.removeEventListener("popupshowing", blockedListener);
    52       SimpleTest.finish();
    53     }, 0);
    54   },
    55   "webapps-ask-install",
    56   false
    57 );
    59 </script>
    61   <!-- Load a page that initiates an app installation and then immediately
    62      - redirects to a page at a different origin.  We can't do this directly
    63      - inside this test page, because that would cause the test to hang. -->
    64   <iframe src="http://test/chrome/dom/tests/mochitest/webapps/install_and_redirect_helper.xul"/>
    66 </window>

mercurial