dom/tests/mochitest/webapps/test_bug_771294.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/webapps/test_bug_771294.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- Any copyright is dedicated to the Public Domain.
     1.7 +   - http://creativecommons.org/publicdomain/zero/1.0/ -->
     1.8 +
     1.9 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
    1.10 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
    1.11 +
    1.12 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.13 +        title="Mozilla Bug 771294">
    1.14 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.15 +  <script type="application/javascript" src="head.js"/>
    1.16 +  <!-- test results are displayed in the html:body -->
    1.17 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.18 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771294"
    1.19 +     target="_blank">Mozilla Bug 771294</a>
    1.20 +  </body>
    1.21 +
    1.22 +<script>
    1.23 +const Ci = Components.interfaces;
    1.24 +const Cu = Components.utils;
    1.25 +
    1.26 +SimpleTest.waitForExplicitFinish();
    1.27 +
    1.28 +SpecialPowers.setAllAppsLaunchable(true);
    1.29 +
    1.30 +Cu.import("resource://gre/modules/Services.jsm");
    1.31 +Cu.import("resource://gre/modules/PopupNotifications.jsm");
    1.32 +
    1.33 +let blocked = true;
    1.34 +
    1.35 +function blockedListener() {
    1.36 +  blocked = false;
    1.37 +}
    1.38 +
    1.39 +let panel = window.top.QueryInterface(Ci.nsIInterfaceRequestor)
    1.40 +                  .getInterface(Ci.nsIWebNavigation)
    1.41 +                  .QueryInterface(Ci.nsIDocShell)
    1.42 +                  .chromeEventHandler.ownerDocument.defaultView
    1.43 +                  .PopupNotifications.panel;
    1.44 +
    1.45 +panel.addEventListener("popupshowing", blockedListener, false);
    1.46 +
    1.47 +Services.obs.addObserver(
    1.48 +  function observeInstalling() {
    1.49 +    Services.obs.removeObserver(observeInstalling, "webapps-ask-install");
    1.50 +    // Spin the event loop before running the test to give the registry time
    1.51 +    // to process the install request and (hopefully not) show the doorhanger.
    1.52 +    setTimeout(function verify() {
    1.53 +      ok(blocked, "Install panel was blocked after immediate redirect");
    1.54 +      panel.removeEventListener("popupshowing", blockedListener);
    1.55 +      SimpleTest.finish();
    1.56 +    }, 0);
    1.57 +  },
    1.58 +  "webapps-ask-install",
    1.59 +  false
    1.60 +);
    1.61 +
    1.62 +</script>
    1.63 +
    1.64 +  <!-- Load a page that initiates an app installation and then immediately
    1.65 +     - redirects to a page at a different origin.  We can't do this directly
    1.66 +     - inside this test page, because that would cause the test to hang. -->
    1.67 +  <iframe src="http://test/chrome/dom/tests/mochitest/webapps/install_and_redirect_helper.xul"/>
    1.68 +
    1.69 +</window>

mercurial