зеркало из https://github.com/mozilla/gecko-dev.git
Bug 664379 - make callbacks for head.js functions optional where appropriate; r=dao
This commit is contained in:
Родитель
b29420d1b6
Коммит
a5fd780f5d
|
@ -10,7 +10,7 @@ function test() {
|
|||
registerCleanupFunction(function() {
|
||||
while (gBrowser.tabs[1])
|
||||
gBrowser.removeTab(gBrowser.tabs[1]);
|
||||
hideTabView(function() {});
|
||||
hideTabView();
|
||||
});
|
||||
gBrowser.loadOneTab("about:blank", { inBackground: true });
|
||||
showTabView(setup);
|
||||
|
@ -20,7 +20,7 @@ function setup() {
|
|||
registerCleanupFunction(function() {
|
||||
let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
|
||||
if (groupItem)
|
||||
closeGroupItem(groupItem, function() {});
|
||||
closeGroupItem(groupItem);
|
||||
});
|
||||
|
||||
let contentWindow = TabView.getContentWindow();
|
||||
|
|
|
@ -15,7 +15,7 @@ function test() {
|
|||
registerCleanupFunction(function() {
|
||||
while (gBrowser.tabs[1])
|
||||
gBrowser.removeTab(gBrowser.tabs[1]);
|
||||
hideTabView(function() {});
|
||||
hideTabView();
|
||||
});
|
||||
|
||||
showTabView(function() {
|
||||
|
@ -24,7 +24,7 @@ function test() {
|
|||
registerCleanupFunction(function() {
|
||||
let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
|
||||
if (groupItem)
|
||||
closeGroupItem(groupItem, function() {});
|
||||
closeGroupItem(groupItem);
|
||||
});
|
||||
|
||||
is(contentWindow.GroupItems.groupItems.length, 1,
|
||||
|
|
|
@ -10,7 +10,7 @@ function test() {
|
|||
registerCleanupFunction(function() {
|
||||
if (gBrowser.tabs.length > 1)
|
||||
gBrowser.removeTab(gBrowser.tabs[1]);
|
||||
hideTabView(function() {});
|
||||
hideTabView();
|
||||
});
|
||||
|
||||
showTabView(function() {
|
||||
|
|
|
@ -15,7 +15,7 @@ function test() {
|
|||
HttpRequestObserver.unregister();
|
||||
if (gBrowser.tabs[1])
|
||||
gBrowser.removeTab(gBrowser.tabs[1]);
|
||||
hideTabView(function () {});
|
||||
hideTabView();
|
||||
|
||||
contentWindow.ThumbnailStorage.enablePersistentHttpsCaching =
|
||||
enablePersistentHttpsCaching;
|
||||
|
|
|
@ -29,11 +29,11 @@ function test() {
|
|||
|
||||
registerCleanupFunction(function () {
|
||||
hideMoveToGroupPopup();
|
||||
hideTabView(function () {});
|
||||
hideTabView();
|
||||
|
||||
let groupItems = TabView.getContentWindow().GroupItems.groupItems;
|
||||
if (groupItems.length > 1)
|
||||
closeGroupItem(groupItems[0], function () {});
|
||||
closeGroupItem(groupItems[0]);
|
||||
});
|
||||
|
||||
showTabView(function () {
|
||||
|
|
|
@ -8,7 +8,7 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
hideTabView(function () {});
|
||||
hideTabView();
|
||||
});
|
||||
|
||||
showTabView(function() {
|
||||
|
|
|
@ -12,8 +12,8 @@ function test() {
|
|||
contentWindow.gPrefBranch.clearUserPref("animate_zoom");
|
||||
let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId)
|
||||
if (createdGroupItem)
|
||||
closeGroupItem(createdGroupItem, function() {});
|
||||
hideTabView(function() {});
|
||||
closeGroupItem(createdGroupItem);
|
||||
hideTabView();
|
||||
});
|
||||
|
||||
showTabView(function() {
|
||||
|
|
|
@ -7,7 +7,7 @@ function test() {
|
|||
registerCleanupFunction(function() {
|
||||
while (gBrowser.tabs[1])
|
||||
gBrowser.removeTab(gBrowser.tabs[1]);
|
||||
hideTabView(function() {});
|
||||
hideTabView();
|
||||
});
|
||||
showTabView(onTabViewWindowLoaded);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ function onTabViewWindowLoaded() {
|
|||
registerCleanupFunction(function() {
|
||||
let groupItem = contentWindow.GroupItems.groupItem(groupItemId);
|
||||
if (groupItem)
|
||||
closeGroupItem(groupItem, function() {});
|
||||
closeGroupItem(groupItem);
|
||||
});
|
||||
|
||||
// create a group item
|
||||
|
|
|
@ -48,11 +48,12 @@ function createGroupItemWithBlankTabs(win, width, height, padding, numNewTabs, a
|
|||
|
||||
// ----------
|
||||
function closeGroupItem(groupItem, callback) {
|
||||
groupItem.addSubscriber("close", function onClose() {
|
||||
groupItem.removeSubscriber("close", onClose);
|
||||
if ("function" == typeof callback)
|
||||
if (callback) {
|
||||
groupItem.addSubscriber("close", function onClose() {
|
||||
groupItem.removeSubscriber("close", onClose);
|
||||
executeSoon(callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (groupItem.getChildren().length) {
|
||||
groupItem.addSubscriber("groupHidden", function onHide() {
|
||||
|
@ -140,9 +141,10 @@ function showTabView(callback, win) {
|
|||
return;
|
||||
}
|
||||
|
||||
whenTabViewIsShown(function() {
|
||||
whenTabViewIsShown(function () {
|
||||
waitForFocus(callback, win);
|
||||
}, win);
|
||||
|
||||
win.TabView.show();
|
||||
}
|
||||
|
||||
|
@ -151,11 +153,14 @@ function hideTabView(callback, win) {
|
|||
win = win || window;
|
||||
|
||||
if (!win.TabView.isVisible()) {
|
||||
callback();
|
||||
if (callback)
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
whenTabViewIsHidden(callback, win);
|
||||
if (callback)
|
||||
whenTabViewIsHidden(callback, win);
|
||||
|
||||
win.TabView.hide();
|
||||
}
|
||||
|
||||
|
@ -189,31 +194,20 @@ function whenTabViewIsShown(callback, win) {
|
|||
}, false);
|
||||
}
|
||||
|
||||
// ----------
|
||||
function showSearch(callback, win) {
|
||||
win = win || window;
|
||||
|
||||
let contentWindow = win.TabView.getContentWindow();
|
||||
if (contentWindow.isSearchEnabled()) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
whenSearchIsEnabled(callback, win);
|
||||
contentWindow.performSearch();
|
||||
}
|
||||
|
||||
// ----------
|
||||
function hideSearch(callback, win) {
|
||||
win = win || window;
|
||||
|
||||
let contentWindow = win.TabView.getContentWindow();
|
||||
if (!contentWindow.isSearchEnabled()) {
|
||||
callback();
|
||||
if (callback)
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
whenSearchIsDisabled(callback, win);
|
||||
if (callback)
|
||||
whenSearchIsDisabled(callback, win);
|
||||
|
||||
contentWindow.hideSearch();
|
||||
}
|
||||
|
||||
|
@ -253,28 +247,36 @@ function whenSearchIsDisabled(callback, win) {
|
|||
// ----------
|
||||
function hideGroupItem(groupItem, callback) {
|
||||
if (groupItem.hidden) {
|
||||
callback();
|
||||
if (callback)
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
groupItem.addSubscriber("groupHidden", function onHide() {
|
||||
groupItem.removeSubscriber("groupHidden", onHide);
|
||||
callback();
|
||||
});
|
||||
if (callback) {
|
||||
groupItem.addSubscriber("groupHidden", function onHide() {
|
||||
groupItem.removeSubscriber("groupHidden", onHide);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
groupItem.closeAll();
|
||||
}
|
||||
|
||||
// ----------
|
||||
function unhideGroupItem(groupItem, callback) {
|
||||
if (!groupItem.hidden) {
|
||||
callback();
|
||||
if (callback)
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
groupItem.addSubscriber("groupShown", function onShown() {
|
||||
groupItem.removeSubscriber("groupShown", onShown);
|
||||
callback();
|
||||
});
|
||||
if (callback) {
|
||||
groupItem.addSubscriber("groupShown", function onShown() {
|
||||
groupItem.removeSubscriber("groupShown", onShown);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
groupItem._unhide();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче