Bug 1486050 - Don't change selected tab when browser.tabs.update is called with {highlighted: true, active: false}. r=mixedpuppy

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Oriol Brufau 2018-08-27 11:53:42 +00:00
Родитель cbab098175
Коммит f81e9b49d1
2 изменённых файлов: 16 добавлений и 14 удалений

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

@ -712,9 +712,12 @@ this.tabs = class extends ExtensionAPI {
if (updateProperties.highlighted) {
if (!nativeTab.selected && !nativeTab.multiselected) {
tabbrowser.addToMultiSelectedTabs(nativeTab, false);
// Select the highlighted tab, this matches Chrome's behavior.
tabbrowser.lockClearMultiSelectionOnce();
tabbrowser.selectedTab = nativeTab;
// Select the highlighted tab unless active:false is provided.
// Note that Chrome selects it even in that case.
if (updateProperties.active !== false) {
tabbrowser.lockClearMultiSelectionOnce();
tabbrowser.selectedTab = nativeTab;
}
}
} else {
tabbrowser.removeFromMultiSelectedTabs(nativeTab, true);

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

@ -115,25 +115,24 @@ add_task(async function test_update_highlighted() {
await expectResults(async () => {
await browser.tabs.update(tab2, {highlighted: true, active: false});
return {active: tab2, highlighted: [tab1, tab2], events: [
["onActivated", {tabId: tab2, windowId}],
return {active: tab1, highlighted: [tab1, tab2], events: [
["onHighlighted", {tabIds: [tab1, tab2], windowId}],
]};
}, "highlighting and (not really) inactivating non-highlighted tab");
}, "highlighting without activating non-highlighted tab");
await expectResults(async () => {
await browser.tabs.update(tab1, {highlighted: true, active: true});
return {active: tab1, highlighted: [tab1], events: [
["onActivated", {tabId: tab1, windowId}],
["onHighlighted", {tabIds: [tab1], windowId}],
await browser.tabs.update(tab2, {highlighted: true, active: true});
return {active: tab2, highlighted: [tab2], events: [
["onActivated", {tabId: tab2, windowId}],
["onHighlighted", {tabIds: [tab2], windowId}],
]};
}, "highlighting and activating inactive highlighted tab");
await expectResults(async () => {
await browser.tabs.update(tab2, {active: true, highlighted: true});
return {active: tab2, highlighted: [tab2], events: [
["onActivated", {tabId: tab2, windowId}],
["onHighlighted", {tabIds: [tab2], windowId}],
await browser.tabs.update(tab1, {active: true, highlighted: true});
return {active: tab1, highlighted: [tab1], events: [
["onActivated", {tabId: tab1, windowId}],
["onHighlighted", {tabIds: [tab1], windowId}],
]};
}, "highlighting and activating non-highlighted tab");