michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: function waitForActive() { michael@0: if (!gBrowser.docShell.isActive) { michael@0: executeSoon(waitForActive); michael@0: return; michael@0: } michael@0: is(gBrowser.docShell.isActive, true, "Docshell should be active again"); michael@0: finish(); michael@0: } michael@0: michael@0: function waitForInactive() { michael@0: if (gBrowser.docShell.isActive) { michael@0: executeSoon(waitForInactive); michael@0: return; michael@0: } michael@0: is(gBrowser.docShell.isActive, false, "Docshell should be inactive"); michael@0: window.restore(); michael@0: waitForActive(); michael@0: } michael@0: michael@0: function test() { michael@0: registerCleanupFunction(function() { michael@0: window.restore(); michael@0: }); michael@0: michael@0: waitForExplicitFinish(); michael@0: is(gBrowser.docShell.isActive, true, "Docshell should be active"); michael@0: window.minimize(); michael@0: // XXX On Linux minimize/restore seem to be very very async, but michael@0: // our window.windowState changes sync.... so we can't rely on the michael@0: // latter correctly reflecting the state of the former. In michael@0: // particular, a restore() call before minimizing is done will not michael@0: // actually restore the window, but change the window state. As a michael@0: // result, just poll waiting for our expected isActive values. michael@0: waitForInactive(); michael@0: }