Bug 593645 - Use popup.triggerNode for tab context menu - tests. r=dao

This commit is contained in:
Frank Yan 2012-01-18 03:55:23 -08:00
parent 75e13ed8fd
commit bdb01440f4
8 changed files with 22 additions and 27 deletions

View File

@ -91,6 +91,7 @@ endif
# browser_bug321000.js is disabled because newline handling is shaky (bug 592528)
_BROWSER_FILES = \
head.js \
browser_typeAheadFind.js \
browser_keywordSearch.js \
browser_allTabsPanel.js \

View File

@ -4,9 +4,7 @@ function numClosedTabs()
getClosedTabCount(window);
function isUndoCloseEnabled() {
document.popupNode = gBrowser.tabs[0];
TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
TabContextMenu.contextTab = null;
updateTabContextMenu();
return !document.getElementById("context_undoCloseTab").disabled;
}

View File

@ -89,15 +89,11 @@ function test() {
}
function Disabled() {
document.popupNode = gBrowser.selectedTab;
TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
TabContextMenu.contextTab = null;
updateTabContextMenu();
return document.getElementById("Browser:BookmarkAllTabs").getAttribute("disabled") == "true";
}
function Hidden() {
document.popupNode = gBrowser.selectedTab;
TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
TabContextMenu.contextTab = null;
updateTabContextMenu();
return document.getElementById("context_bookmarkAllTabs").hidden;
}

View File

@ -43,7 +43,7 @@ function test() {
is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs");
// Check the context menu with two tabs
popup(origTab);
updateTabContextMenu(origTab);
is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled");
is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled");
@ -53,7 +53,7 @@ function test() {
is(gBrowser.visibleTabs.length, 1, "now there is only one visible tab");
// Check the context menu with one tab.
popup(testTab);
updateTabContextMenu(testTab);
is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists");
is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled");
@ -64,7 +64,7 @@ function test() {
is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs");
// Check the context menu on the unpinned visible tab
popup(testTab);
updateTabContextMenu(testTab);
is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled");
// Show all tabs
@ -72,16 +72,9 @@ function test() {
gBrowser.showOnlyTheseTabs(allTabs);
// Check the context menu now
popup(testTab);
updateTabContextMenu(testTab);
is(document.getElementById("context_closeOtherTabs").disabled, false, "Close Other Tabs is enabled");
gBrowser.removeTab(testTab);
gBrowser.removeTab(pinned);
}
function popup(tab) {
document.popupNode = tab;
TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
TabContextMenu.contextTab = null;
}

View File

@ -0,0 +1,8 @@
function updateTabContextMenu(tab) {
let menu = document.getElementById("tabContextMenu");
if (!tab)
tab = gBrowser.selectedTab;
menu.openPopup(tab, "end_after", 0, 0, true, false, {target: tab});
is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
menu.hidePopup();
}

View File

@ -47,9 +47,10 @@ function test() {
}
function popup(tab) {
document.popupNode = tab;
TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
let menu = document.getElementById("tabContextMenu");
menu.openPopup(tab, "end_after", 0, 0, true, false, {target: tab});
TabContextMenu.updateContextMenu(menu);
is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
TabContextMenu.contextTab = null;
menu.hidePopup();
}

View File

@ -138,9 +138,8 @@ function test3(win) {
}
function openTabContextPopup(win, tab) {
win.document.popupNode = tab;
win.document.getElementById("tabContextMenu").openPopup(
tab, "end_after", 0, 0, true, false);
tab, "end_after", 0, 0, true, false, {target: tab});
}
function closeTabContextPopup(win) {

View File

@ -4,8 +4,7 @@
function test() {
let openMoveToGroupPopup = function () {
let tab = gBrowser.selectedTab;
document.popupNode = tab;
contextMenu.openPopup(tab, "end_after", 0, 0, true, false);
contextMenu.openPopup(tab, "end_after", 0, 0, true, false, {target: tab});
tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false);
}