Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 function test() {
2 gBrowser.tabContainer.addEventListener("TabOpen", tabAdded, false);
4 var tab = gBrowser.addTab("about:blank", { skipAnimation: true });
5 gBrowser.removeTab(tab);
6 is(tab.parentNode, null, "tab removed immediately");
8 tab = gBrowser.addTab("about:blank", { skipAnimation: true });
9 gBrowser.removeTab(tab, { animate: true });
10 gBrowser.removeTab(tab);
11 is(tab.parentNode, null, "tab removed immediately when calling removeTab again after the animation was kicked off");
13 waitForExplicitFinish();
15 Services.prefs.setBoolPref("browser.tabs.animate", true);
17 // preperForNextText();
18 todo(false, "async tests disabled because of intermittent failures (bug 585361)");
19 cleanup();
20 }
22 function tabAdded() {
23 info("tab added");
24 }
26 function cleanup() {
27 if (Services.prefs.prefHasUserValue("browser.tabs.animate"))
28 Services.prefs.clearUserPref("browser.tabs.animate");
29 gBrowser.tabContainer.removeEventListener("TabOpen", tabAdded, false);
30 finish();
31 }
33 var asyncTests = [
34 function (tab) {
35 info("closing tab with middle click");
36 EventUtils.synthesizeMouse(tab, 2, 2, { button: 1 });
37 },
38 function (tab) {
39 info("closing tab with accel+w");
40 gBrowser.selectedTab = tab;
41 gBrowser.selectedBrowser.focus();
42 EventUtils.synthesizeKey("w", { accelKey: true });
43 },
44 function (tab) {
45 info("closing tab by clicking the tab close button");
46 gBrowser.selectedTab = tab;
47 var button = document.getAnonymousElementByAttribute(tab, "anonid", "close-button");
48 EventUtils.synthesizeMouse(button, 2, 2, {});
49 }
50 ];
52 function preperForNextText() {
53 info("tests left: " + asyncTests.length + "; starting next");
54 var tab = gBrowser.addTab("about:blank", { skipAnimation: true });
55 executeSoon(function () {
56 nextAsyncText(tab);
57 });
58 }
60 function nextAsyncText(tab) {
61 var gotCloseEvent = false;
63 tab.addEventListener("TabClose", function () {
64 tab.removeEventListener("TabClose", arguments.callee, false);
65 info("got TabClose event");
66 gotCloseEvent = true;
68 const DEFAULT_ANIMATION_LENGTH = 250;
69 const MAX_WAIT_TIME = DEFAULT_ANIMATION_LENGTH * 7;
70 var polls = Math.ceil(MAX_WAIT_TIME / DEFAULT_ANIMATION_LENGTH);
71 var pollTabRemoved = setInterval(function () {
72 --polls;
73 if (tab.parentNode && polls > 0)
74 return;
75 clearInterval(pollTabRemoved);
77 is(tab.parentNode, null, "tab removed after at most " + MAX_WAIT_TIME + " ms");
79 if (asyncTests.length)
80 preperForNextText();
81 else
82 cleanup();
83 }, DEFAULT_ANIMATION_LENGTH);
84 }, false);
86 asyncTests.shift()(tab);
88 ok(gotCloseEvent, "got the close event syncronously");
90 is(tab.parentNode, gBrowser.tabContainer, "tab still exists when it's about to be removed asynchronously");
91 }