browser/base/content/test/general/browser_minimize.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_minimize.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +function waitForActive() {
     1.7 +    if (!gBrowser.docShell.isActive) {
     1.8 +        executeSoon(waitForActive);
     1.9 +        return;
    1.10 +    }
    1.11 +    is(gBrowser.docShell.isActive, true, "Docshell should be active again");
    1.12 +    finish();
    1.13 +}
    1.14 +
    1.15 +function waitForInactive() {
    1.16 +    if (gBrowser.docShell.isActive) {
    1.17 +        executeSoon(waitForInactive);
    1.18 +        return;
    1.19 +    }
    1.20 +    is(gBrowser.docShell.isActive, false, "Docshell should be inactive");
    1.21 +    window.restore();
    1.22 +    waitForActive();
    1.23 +}
    1.24 +
    1.25 +function test() {
    1.26 +    registerCleanupFunction(function() {
    1.27 +      window.restore();
    1.28 +    });
    1.29 +
    1.30 +    waitForExplicitFinish();
    1.31 +    is(gBrowser.docShell.isActive, true, "Docshell should be active");
    1.32 +    window.minimize();
    1.33 +    // XXX On Linux minimize/restore seem to be very very async, but
    1.34 +    // our window.windowState changes sync.... so we can't rely on the
    1.35 +    // latter correctly reflecting the state of the former.  In
    1.36 +    // particular, a restore() call before minimizing is done will not
    1.37 +    // actually restore the window, but change the window state.  As a
    1.38 +    // result, just poll waiting for our expected isActive values.
    1.39 +    waitForInactive();
    1.40 +}

mercurial