Bug 1481473 - Hide the 'Duplicate Tab' menuitem when there is a selection of tabs. r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D4549

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jared Wein 2018-08-29 18:07:30 +00:00
Родитель 01d16686d3
Коммит bac44c8022
3 изменённых файлов: 53 добавлений и 0 удалений

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

@ -5268,6 +5268,10 @@ var TabContextMenu = {
let contextUnpinSelectedTabs = document.getElementById("context_unpinSelectedTabs");
contextUnpinSelectedTabs.hidden = !this.contextTab.pinned || !multiselectionContext;
// Hide the "Duplicate Tab" if there is a selection present
let contextDuplicateTab = document.getElementById("context_duplicateTab");
contextDuplicateTab.hidden = multiselectionContext;
// Disable "Close Tabs to the Right" if there are no tabs
// following it.
document.getElementById("context_closeTabsToTheEnd").disabled =

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

@ -27,6 +27,7 @@ support-files =
[browser_multiselect_tabs_close_using_shortcuts.js]
[browser_multiselect_tabs_close.js]
[browser_multiselect_tabs_copy_through_drag_and_drop.js]
[browser_multiselect_tabs_duplicate.js]
[browser_multiselect_tabs_event.js]
[browser_multiselect_tabs_move_to_another_window_drag.js]
[browser_multiselect_tabs_move_to_new_window_contextmenu.js]

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

@ -0,0 +1,48 @@
const PREF_MULTISELECT_TABS = "browser.tabs.multiselect";
add_task(async function setPref() {
await SpecialPowers.pushPrefEnv({
set: [[PREF_MULTISELECT_TABS, true]]
});
});
add_task(async function test() {
let tab1 = await addTab();
let tab2 = await addTab();
let tab3 = await addTab();
let menuItemDuplicateTab = document.getElementById("context_duplicateTab");
is(gBrowser.multiSelectedTabsCount, 0, "Zero multiselected tabs");
await BrowserTestUtils.switchTab(gBrowser, tab1);
await triggerClickOn(tab2, { ctrlKey: true });
ok(tab1.multiselected, "Tab1 is multiselected");
ok(tab2.multiselected, "Tab2 is multiselected");
ok(!tab3.multiselected, "Tab3 is not multiselected");
// Check the context menu with a multiselected tabs
updateTabContextMenu(tab2);
is(menuItemDuplicateTab.hidden, true, "Duplicate Tab is hidden");
// Check the context menu with a non-multiselected tab
updateTabContextMenu(tab3);
is(menuItemDuplicateTab.hidden, false, "Duplicate Tab is visible");
let newTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, "http://mochi.test:8888/");
window.TabContextMenu.contextTab = tab3; // Set proper context for command handler
menuItemDuplicateTab.click();
let tab4 = await newTabOpened;
// Selection should be cleared after duplication
ok(!tab1.multiselected, "Tab1 is not multiselected");
ok(!tab2.multiselected, "Tab2 is not multiselected");
ok(!tab4.multiselected, "Tab3 is not multiselected");
ok(!tab3.multiselected, "Tab4 is not multiselected");
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);
BrowserTestUtils.removeTab(tab3);
BrowserTestUtils.removeTab(tab4);
});