dom/tests/mochitest/webapps/head.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/webapps/head.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function runAll(steps) {
     1.8 +  SimpleTest.waitForExplicitFinish();
     1.9 +
    1.10 +  /**
    1.11 +   * On Mac, apps aren't considered launchable right after they've been
    1.12 +   * installed because the OS takes some time to detect them (so
    1.13 +   * nsIMacWebAppUtils::pathForAppWithIdentifier() returns null).
    1.14 +   * That causes methods like mgmt.getAll() to exclude the app from their
    1.15 +   * results, even though the app is installed and is in the registry.
    1.16 +   * See the tests under toolkit/webapps for a viable solution.
    1.17 +   *
    1.18 +   * To work around this problem, set allAppsLaunchable to true, which makes
    1.19 +   * all apps considered as launchable.
    1.20 +   */
    1.21 +  SpecialPowers.setAllAppsLaunchable(true);
    1.22 +
    1.23 +  // Clone the array so we don't modify the original.
    1.24 +  steps = steps.concat();
    1.25 +  function next() {
    1.26 +    if (steps.length) {
    1.27 +      steps.shift()(next);
    1.28 +    }
    1.29 +    else {
    1.30 +      SimpleTest.finish();
    1.31 +    }
    1.32 +  }
    1.33 +  next();
    1.34 +}
    1.35 +
    1.36 +function confirmNextInstall() {
    1.37 +  var Ci = SpecialPowers.Ci;
    1.38 +
    1.39 +  var popupPanel = SpecialPowers.wrap(window).top.
    1.40 +                   QueryInterface(Ci.nsIInterfaceRequestor).
    1.41 +                   getInterface(Ci.nsIWebNavigation).
    1.42 +                   QueryInterface(Ci.nsIDocShell).
    1.43 +                   chromeEventHandler.ownerDocument.defaultView.
    1.44 +                   PopupNotifications.panel;
    1.45 +
    1.46 +  function onPopupShown() {
    1.47 +    popupPanel.removeEventListener("popupshown", onPopupShown, false);
    1.48 +    SpecialPowers.wrap(this).childNodes[0].button.doCommand();
    1.49 +  }
    1.50 +  popupPanel.addEventListener("popupshown", onPopupShown, false);
    1.51 +}

mercurial