Bug 984843 - Try to fix intermittent timeouts and leaks r=ehsan

From 55be314a97a4934167ad466dc884fb5c933dea1e Mon Sep 17 00:00:00 2001
This commit is contained in:
Tim Taubert 2014-03-26 09:27:19 +01:00
Родитель 24d3f3ce26
Коммит 18f1360735
2 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@ -7,10 +7,6 @@ function test() {
waitForExplicitFinish();
newWindowWithTabView(function(win) {
registerCleanupFunction(function() {
win.close();
});
cw = win.TabView.getContentWindow();
let groupItemOne = cw.GroupItems.groupItems[0];
@ -22,11 +18,13 @@ function test() {
let groupItemThree = createGroupItemWithBlankTabs(win, 300, 300, 40, 2);
is(groupItemThree.getChildren().length, 2, "Group three has 2 tab items");
waitForFocus(() => {
testMoreRecentlyUsedGroup(groupItemOne, groupItemTwo, function() {
testMoreRecentlyUsedGroup(groupItemOne, groupItemThree, function() {
testRemoveGroupAndCheckMoreRecentlyUsedGroup(groupItemOne, groupItemTwo);
});
});
}, cw);
});
}
@ -81,12 +79,14 @@ function testRemoveGroupAndCheckMoreRecentlyUsedGroup(groupItemOne, groupItemTwo
is(groupItemTwo.getActiveTab(), tabItem, "The first item in the group two is still active after group one is closed");
is(cw.GroupItems.getActiveGroupItem(), groupItemTwo, "The group two is still active after group one is closed");
promiseWindowClosed(cw.top).then(() => {
cw = null;
finish();
});
});
// close the tab item and the group item
let closeButton = tabItemInGroupItemOne.container.getElementsByClassName("close");
ok(closeButton[0], "Tab item close button exists");
EventUtils.sendMouseEvent({ type: "mousedown" }, closeButton[0], cw);
EventUtils.sendMouseEvent({ type: "mouseup" }, closeButton[0], cw);
}

Просмотреть файл

@ -400,3 +400,21 @@ function whenAppTabIconAdded(groupItem, callback) {
executeSoon(callback);
});
}
/**
* Chrome windows aren't closed synchronously. Provide a helper method to close
* a window and wait until we received the "domwindowclosed" notification for it.
*/
function promiseWindowClosed(win) {
let deferred = Promise.defer();
Services.obs.addObserver(function obs(subject, topic) {
if (subject == win) {
Services.obs.removeObserver(obs, topic);
deferred.resolve();
}
}, "domwindowclosed", false);
win.close();
return deferred.promise;
}