2010-08-06 13:15:18 -07:00
|
|
|
function test() {
|
2010-08-07 14:19:18 -07:00
|
|
|
gBrowser.tabContainer.addEventListener("TabOpen", tabAdded, false);
|
|
|
|
|
2010-08-06 13:15:18 -07:00
|
|
|
var tab = gBrowser.addTab("about:blank", { skipAnimation: true });
|
|
|
|
gBrowser.removeTab(tab);
|
|
|
|
is(tab.parentNode, null, "tab removed immediately");
|
|
|
|
|
2010-08-11 06:12:54 -07:00
|
|
|
tab = gBrowser.addTab("about:blank", { skipAnimation: true });
|
|
|
|
gBrowser.removeTab(tab, { animate: true });
|
|
|
|
gBrowser.removeTab(tab);
|
|
|
|
is(tab.parentNode, null, "tab removed immediately when calling removeTab again after the animation was kicked off");
|
|
|
|
|
2010-08-06 13:15:18 -07:00
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
Services.prefs.setBoolPref("browser.tabs.animate", true);
|
2010-08-24 07:13:28 -07:00
|
|
|
|
|
|
|
// preperForNextText();
|
|
|
|
todo(false, "async tests disabled because of intermittent failures (bug 585361)");
|
|
|
|
cleanup();
|
2010-08-06 13:15:18 -07:00
|
|
|
}
|
|
|
|
|
2010-08-07 14:19:18 -07:00
|
|
|
function tabAdded() {
|
|
|
|
info("tab added");
|
|
|
|
}
|
|
|
|
|
2010-08-06 13:15:18 -07:00
|
|
|
function cleanup() {
|
|
|
|
if (Services.prefs.prefHasUserValue("browser.tabs.animate"))
|
|
|
|
Services.prefs.clearUserPref("browser.tabs.animate");
|
2010-08-07 14:19:18 -07:00
|
|
|
gBrowser.tabContainer.removeEventListener("TabOpen", tabAdded, false);
|
2010-08-06 13:15:18 -07:00
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
var asyncTests = [
|
|
|
|
function (tab) {
|
|
|
|
info("closing tab with middle click");
|
|
|
|
EventUtils.synthesizeMouse(tab, 2, 2, { button: 1 });
|
|
|
|
},
|
|
|
|
function (tab) {
|
|
|
|
info("closing tab with accel+w");
|
|
|
|
gBrowser.selectedTab = tab;
|
|
|
|
content.focus();
|
|
|
|
EventUtils.synthesizeKey("w", { accelKey: true });
|
|
|
|
},
|
|
|
|
function (tab) {
|
|
|
|
info("closing tab by clicking the tab close button");
|
|
|
|
gBrowser.selectedTab = tab;
|
|
|
|
var button = document.getAnonymousElementByAttribute(tab, "anonid", "close-button");
|
|
|
|
EventUtils.synthesizeMouse(button, 2, 2, {});
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2010-08-20 00:21:06 -07:00
|
|
|
function preperForNextText() {
|
2010-08-07 14:19:18 -07:00
|
|
|
info("tests left: " + asyncTests.length + "; starting next");
|
2010-08-06 13:15:18 -07:00
|
|
|
var tab = gBrowser.addTab("about:blank", { skipAnimation: true });
|
2010-08-20 00:21:06 -07:00
|
|
|
executeSoon(function () {
|
|
|
|
nextAsyncText(tab);
|
|
|
|
});
|
|
|
|
}
|
2010-08-06 13:15:18 -07:00
|
|
|
|
2010-08-20 00:21:06 -07:00
|
|
|
function nextAsyncText(tab) {
|
2010-08-06 13:15:18 -07:00
|
|
|
var gotCloseEvent = false;
|
|
|
|
|
|
|
|
tab.addEventListener("TabClose", function () {
|
2011-06-07 07:45:26 -07:00
|
|
|
tab.removeEventListener("TabClose", arguments.callee, false);
|
2010-08-07 14:19:18 -07:00
|
|
|
info("got TabClose event");
|
2010-08-06 13:15:18 -07:00
|
|
|
gotCloseEvent = true;
|
|
|
|
|
|
|
|
const DEFAULT_ANIMATION_LENGTH = 250;
|
2010-08-09 01:01:29 -07:00
|
|
|
const MAX_WAIT_TIME = DEFAULT_ANIMATION_LENGTH * 7;
|
2010-08-08 11:53:35 -07:00
|
|
|
var polls = Math.ceil(MAX_WAIT_TIME / DEFAULT_ANIMATION_LENGTH);
|
2010-08-06 13:15:18 -07:00
|
|
|
var pollTabRemoved = setInterval(function () {
|
|
|
|
--polls;
|
|
|
|
if (tab.parentNode && polls > 0)
|
|
|
|
return;
|
|
|
|
clearInterval(pollTabRemoved);
|
|
|
|
|
|
|
|
is(tab.parentNode, null, "tab removed after at most " + MAX_WAIT_TIME + " ms");
|
|
|
|
|
|
|
|
if (asyncTests.length)
|
2010-08-20 00:21:06 -07:00
|
|
|
preperForNextText();
|
2010-08-06 13:15:18 -07:00
|
|
|
else
|
|
|
|
cleanup();
|
2010-08-08 11:53:35 -07:00
|
|
|
}, DEFAULT_ANIMATION_LENGTH);
|
2010-08-06 13:15:18 -07:00
|
|
|
}, false);
|
|
|
|
|
|
|
|
asyncTests.shift()(tab);
|
|
|
|
|
|
|
|
ok(gotCloseEvent, "got the close event syncronously");
|
|
|
|
|
|
|
|
is(tab.parentNode, gBrowser.tabContainer, "tab still exists when it's about to be removed asynchronously");
|
|
|
|
}
|