Bug 1833804 - Remove some forwarded properties from mail tab types. r=aleca
Differential Revision: https://phabricator.services.mozilla.com/D178418 --HG-- extra : rebase_source : 0518be4b7536af8be72f22245cffd6f275a60cc8
This commit is contained in:
Родитель
a0103fbf7f
Коммит
8e4881d45c
|
@ -306,13 +306,9 @@ function SwitchPaneFocus(event) {
|
|||
let { currentTabInfo } = tabmail;
|
||||
switch (currentTabInfo.mode.name) {
|
||||
case "mail3PaneTab": {
|
||||
let { contentWindow, contentDocument } = currentTabInfo.chromeBrowser;
|
||||
let {
|
||||
chromeBrowser,
|
||||
folderPaneVisible,
|
||||
messagePaneVisible,
|
||||
} = currentTabInfo;
|
||||
let { contentWindow, contentDocument } = chromeBrowser;
|
||||
let {
|
||||
paneLayout,
|
||||
folderTree,
|
||||
threadTree,
|
||||
webBrowser,
|
||||
|
@ -321,7 +317,7 @@ function SwitchPaneFocus(event) {
|
|||
accountCentralBrowser,
|
||||
} = contentWindow;
|
||||
|
||||
if (folderPaneVisible) {
|
||||
if (paneLayout.folderPaneVisible) {
|
||||
panes.push(folderTree);
|
||||
}
|
||||
|
||||
|
@ -331,7 +327,7 @@ function SwitchPaneFocus(event) {
|
|||
panes.push(accountCentralBrowser);
|
||||
}
|
||||
|
||||
if (messagePaneVisible) {
|
||||
if (paneLayout.messagePaneVisible) {
|
||||
if (!webBrowser.hidden) {
|
||||
panes.push(webBrowser);
|
||||
} else if (!messageBrowser.hidden) {
|
||||
|
@ -341,7 +337,7 @@ function SwitchPaneFocus(event) {
|
|||
}
|
||||
}
|
||||
|
||||
if (focusedElement == chromeBrowser) {
|
||||
if (focusedElement == currentTabInfo.chromeBrowser) {
|
||||
focusedElement = contentDocument.activeElement;
|
||||
if (
|
||||
focusedElement != folderTree &&
|
||||
|
|
|
@ -102,12 +102,12 @@ var mailTabType = {
|
|||
Services.telemetry.keyedScalarSet(
|
||||
"tb.ui.configuration.pane_visibility",
|
||||
"folderPane",
|
||||
tab.folderPaneVisible
|
||||
win.paneLayout.folderPaneVisible
|
||||
);
|
||||
Services.telemetry.keyedScalarSet(
|
||||
"tb.ui.configuration.pane_visibility",
|
||||
"messagePane",
|
||||
tab.messagePaneVisible
|
||||
win.paneLayout.messagePaneVisible
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -158,47 +158,6 @@ var mailTabType = {
|
|||
},
|
||||
});
|
||||
|
||||
// Layout properties.
|
||||
Object.defineProperty(tab, "accountCentralVisible", {
|
||||
get() {
|
||||
return tab.chromeBrowser.contentDocument.body.classList.contains(
|
||||
"account-central"
|
||||
);
|
||||
},
|
||||
});
|
||||
Object.defineProperty(tab, "folderPaneVisible", {
|
||||
get() {
|
||||
return !tab.chromeBrowser.contentWindow.folderPaneSplitter
|
||||
?.isCollapsed;
|
||||
},
|
||||
set(visible) {
|
||||
tab.chromeBrowser.contentWindow.folderPaneSplitter.isCollapsed = !visible;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(tab, "messagePaneVisible", {
|
||||
get() {
|
||||
return !tab.chromeBrowser.contentWindow.messagePaneSplitter
|
||||
?.isCollapsed;
|
||||
},
|
||||
set(visible) {
|
||||
tab.chromeBrowser.contentWindow.messagePaneSplitter.isCollapsed = !visible;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(tab, "sort", {
|
||||
get() {
|
||||
return {
|
||||
type:
|
||||
tab.chromeBrowser.contentWindow.gViewWrapper?.primarySortType,
|
||||
order:
|
||||
tab.chromeBrowser.contentWindow.gViewWrapper?.primarySortOrder,
|
||||
grouped:
|
||||
tab.chromeBrowser.contentWindow.gViewWrapper?.showGroupedBySort,
|
||||
threaded:
|
||||
tab.chromeBrowser.contentWindow.gViewWrapper?.showThreaded,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// Content properties.
|
||||
Object.defineProperty(tab, "message", {
|
||||
get() {
|
||||
|
@ -227,9 +186,11 @@ var mailTabType = {
|
|||
}
|
||||
return {
|
||||
firstTab: tab.first,
|
||||
folderPaneVisible: tab.folderPaneVisible,
|
||||
folderPaneVisible:
|
||||
tab.chromeBrowser.contentWindow.paneLayout.folderPaneVisible,
|
||||
folderURI: tab.folder.URI,
|
||||
messagePaneVisible: tab.messagePaneVisible,
|
||||
messagePaneVisible:
|
||||
tab.chromeBrowser.contentWindow.paneLayout.messagePaneVisible,
|
||||
};
|
||||
},
|
||||
restoreTab(tabmail, persistedState) {
|
||||
|
@ -295,12 +256,12 @@ var mailTabType = {
|
|||
Services.telemetry.keyedScalarSet(
|
||||
"tb.ui.configuration.pane_visibility",
|
||||
"folderPane",
|
||||
tab.folderPaneVisible
|
||||
tab.chromeBrowser.contentWindow.paneLayout.folderPaneVisible
|
||||
);
|
||||
Services.telemetry.keyedScalarSet(
|
||||
"tb.ui.configuration.pane_visibility",
|
||||
"messagePane",
|
||||
tab.messagePaneVisible
|
||||
tab.chromeBrowser.contentWindow.paneLayout.messagePaneVisible
|
||||
);
|
||||
},
|
||||
supportsCommand(command, tab) {
|
||||
|
@ -353,7 +314,6 @@ var mailTabType = {
|
|||
});
|
||||
|
||||
// Content properties.
|
||||
tab.messageURI = messageURI;
|
||||
Object.defineProperty(tab, "message", {
|
||||
get() {
|
||||
return tab.chromeBrowser.contentWindow.gMessage;
|
||||
|
@ -366,15 +326,10 @@ var mailTabType = {
|
|||
},
|
||||
});
|
||||
|
||||
tab.chromeBrowser.addEventListener("messageURIChanged", function(
|
||||
event
|
||||
) {
|
||||
tab.messageURI = event.detail;
|
||||
});
|
||||
return tab;
|
||||
},
|
||||
persistTab(tab) {
|
||||
return { messageURI: tab.messageURI };
|
||||
return { messageURI: tab.chromeBrowser.contentWindow.gMessageURI };
|
||||
},
|
||||
restoreTab(tabmail, persistedState) {
|
||||
tabmail.openTab("mailMessageTab", persistedState);
|
||||
|
|
|
@ -25,17 +25,17 @@ add_setup(async function() {
|
|||
rootFolder.createSubfolder("telemetryPlain", null);
|
||||
folders.Other = rootFolder.getChildNamed("telemetryPlain");
|
||||
|
||||
let tab = tabmail.currentTabInfo;
|
||||
let folderPaneVisibleAtStart = tab.folderPaneVisible;
|
||||
let messagePaneVisibleAtStart = tab.messagePaneVisible;
|
||||
let { paneLayout } = tabmail.currentAbout3Pane;
|
||||
let folderPaneVisibleAtStart = paneLayout.folderPaneVisible;
|
||||
let messagePaneVisibleAtStart = paneLayout.messagePaneVisible;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
MailServices.accounts.removeAccount(account, false);
|
||||
tabmail.closeOtherTabs(tab);
|
||||
if (tab.folderPaneVisible != folderPaneVisibleAtStart) {
|
||||
tabmail.closeOtherTabs(0);
|
||||
if (paneLayout.folderPaneVisible != folderPaneVisibleAtStart) {
|
||||
goDoCommand("cmd_toggleFolderPane");
|
||||
}
|
||||
if (tab.messagePaneVisible != messagePaneVisibleAtStart) {
|
||||
if (paneLayout.messagePaneVisible != messagePaneVisibleAtStart) {
|
||||
goDoCommand("cmd_toggleMessagePane");
|
||||
}
|
||||
});
|
||||
|
@ -79,13 +79,13 @@ add_task(async function testFolderOpen() {
|
|||
});
|
||||
|
||||
add_task(async function testPaneVisibility() {
|
||||
let tab = tabmail.currentTabInfo;
|
||||
tabmail.currentAbout3Pane.displayFolder(folders.Other.URI);
|
||||
let { paneLayout, displayFolder } = tabmail.currentAbout3Pane;
|
||||
displayFolder(folders.Other.URI);
|
||||
// Make the folder pane and message pane visible initially.
|
||||
if (!tab.folderPaneVisible) {
|
||||
if (!paneLayout.folderPaneVisible) {
|
||||
goDoCommand("cmd_toggleFolderPane");
|
||||
}
|
||||
if (!tab.messagePaneVisible) {
|
||||
if (!paneLayout.messagePaneVisible) {
|
||||
goDoCommand("cmd_toggleMessagePane");
|
||||
}
|
||||
// The scalar is updated by switching to the folder tab, so open another tab.
|
||||
|
|
|
@ -87,6 +87,7 @@ add_task(async function testTabs() {
|
|||
folderTree,
|
||||
threadTree,
|
||||
messagePane,
|
||||
paneLayout,
|
||||
} = firstChromeBrowser.contentWindow;
|
||||
|
||||
firstTab.folder = folderA;
|
||||
|
@ -112,11 +113,11 @@ add_task(async function testTabs() {
|
|||
Assert.ok(BrowserTestUtils.is_visible(folderTree));
|
||||
Assert.ok(BrowserTestUtils.is_visible(firstMessageBrowser));
|
||||
|
||||
firstTab.folderPaneVisible = false;
|
||||
paneLayout.folderPaneVisible = false;
|
||||
Assert.ok(BrowserTestUtils.is_hidden(folderTree));
|
||||
Assert.ok(BrowserTestUtils.is_visible(firstMessageBrowser));
|
||||
|
||||
firstTab.messagePaneVisible = false;
|
||||
paneLayout.messagePaneVisible = false;
|
||||
Assert.ok(BrowserTestUtils.is_hidden(folderTree));
|
||||
Assert.ok(BrowserTestUtils.is_hidden(firstMessageBrowser));
|
||||
Assert.equal(
|
||||
|
@ -127,11 +128,11 @@ add_task(async function testTabs() {
|
|||
Assert.equal(firstTab.browser, null);
|
||||
Assert.equal(firstTab.linkedBrowser, null);
|
||||
|
||||
firstTab.folderPaneVisible = true;
|
||||
paneLayout.folderPaneVisible = true;
|
||||
Assert.ok(BrowserTestUtils.is_visible(folderTree));
|
||||
Assert.ok(BrowserTestUtils.is_hidden(firstMessageBrowser));
|
||||
|
||||
firstTab.messagePaneVisible = true;
|
||||
paneLayout.messagePaneVisible = true;
|
||||
Assert.ok(BrowserTestUtils.is_visible(folderTree));
|
||||
Assert.ok(BrowserTestUtils.is_visible(firstMessageBrowser));
|
||||
Assert.equal(
|
||||
|
@ -285,7 +286,6 @@ add_task(async function testTabs() {
|
|||
|
||||
Assert.equal(thirdTab.folder, folderB);
|
||||
Assert.equal(thirdTab.message, messagesB[0]);
|
||||
Assert.equal(thirdTab.messageURI, folderB.getUriForMsg(messagesB[0]));
|
||||
|
||||
Assert.equal(thirdChromeBrowser.contentWindow.tabOrWindow, thirdTab);
|
||||
|
||||
|
@ -313,7 +313,6 @@ add_task(async function testTabs() {
|
|||
|
||||
Assert.equal(fourthTab.folder, folderB);
|
||||
Assert.equal(fourthTab.message, messagesB[1]);
|
||||
Assert.equal(fourthTab.messageURI, folderB.getUriForMsg(messagesB[1]));
|
||||
|
||||
Assert.equal(fourthChromeBrowser.contentWindow.tabOrWindow, fourthTab);
|
||||
|
||||
|
|
|
@ -1222,13 +1222,13 @@ class Tab extends TabBase {
|
|||
{
|
||||
// If the messagePane is hidden or all browsers are hidden, there is
|
||||
// nothing to be loaded and we should return complete.
|
||||
let contentWindow = this.nativeTab.chromeBrowser.contentWindow;
|
||||
let about3Pane = this.nativeTab.chromeBrowser.contentWindow;
|
||||
isComplete =
|
||||
!this.nativeTab.messagePaneVisible ||
|
||||
!about3Pane.paneLayout?.messagePaneVisible ||
|
||||
this.browser?.webProgress?.isLoadingDocument === false ||
|
||||
(contentWindow.webBrowser?.hidden &&
|
||||
contentWindow.messageBrowser?.hidden &&
|
||||
contentWindow.multiMessageBrowser?.hidden);
|
||||
(about3Pane.webBrowser?.hidden &&
|
||||
about3Pane.messageBrowser?.hidden &&
|
||||
about3Pane.multiMessageBrowser?.hidden);
|
||||
}
|
||||
break;
|
||||
case "content":
|
||||
|
|
|
@ -52,20 +52,21 @@ function convertMailTab(tab, context) {
|
|||
messagePaneVisible: null,
|
||||
};
|
||||
|
||||
let nativeTab = tab.nativeTab;
|
||||
mailTabObject.folderPaneVisible = nativeTab.folderPaneVisible;
|
||||
mailTabObject.messagePaneVisible = nativeTab.messagePaneVisible;
|
||||
mailTabObject.sortType = SORT_TYPE_MAP.get(nativeTab.sort.type);
|
||||
mailTabObject.sortOrder = SORT_ORDER_MAP.get(nativeTab.sort.order);
|
||||
if (nativeTab.sort.grouped) {
|
||||
let about3Pane = tab.nativeTab.chromeBrowser.contentWindow;
|
||||
let { gViewWrapper, paneLayout } = about3Pane;
|
||||
mailTabObject.folderPaneVisible = paneLayout.folderPaneVisible;
|
||||
mailTabObject.messagePaneVisible = paneLayout.messagePaneVisible;
|
||||
mailTabObject.sortType = SORT_TYPE_MAP.get(gViewWrapper?.primarySortType);
|
||||
mailTabObject.sortOrder = SORT_ORDER_MAP.get(gViewWrapper?.primarySortOrder);
|
||||
if (gViewWrapper?.showGroupedBySort) {
|
||||
mailTabObject.viewType = "groupedBySortType";
|
||||
} else if (nativeTab.sort.threaded) {
|
||||
} else if (gViewWrapper?.showThreaded) {
|
||||
mailTabObject.viewType = "groupedByThread";
|
||||
} else {
|
||||
mailTabObject.viewType = "ungrouped";
|
||||
}
|
||||
if (context.extension.hasPermission("accountsRead")) {
|
||||
mailTabObject.displayedFolder = convertFolder(nativeTab.folder);
|
||||
mailTabObject.displayedFolder = convertFolder(about3Pane.gFolder);
|
||||
}
|
||||
return mailTabObject;
|
||||
}
|
||||
|
@ -321,13 +322,11 @@ this.mailTabs = class extends ExtensionAPIPersistent {
|
|||
);
|
||||
}
|
||||
|
||||
if (nativeTab.mode.name == "mail3PaneTab") {
|
||||
if (typeof folderPaneVisible == "boolean") {
|
||||
nativeTab.folderPaneVisible = folderPaneVisible;
|
||||
}
|
||||
if (typeof messagePaneVisible == "boolean") {
|
||||
nativeTab.messagePaneVisible = messagePaneVisible;
|
||||
}
|
||||
if (typeof folderPaneVisible == "boolean") {
|
||||
about3Pane.paneLayout.folderPaneVisible = folderPaneVisible;
|
||||
}
|
||||
if (typeof messagePaneVisible == "boolean") {
|
||||
about3Pane.paneLayout.messagePaneVisible = messagePaneVisible;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -103,7 +103,8 @@ registerCleanupFunction(() => {
|
|||
});
|
||||
|
||||
async function check3PaneState(folderPaneOpen = null, messagePaneOpen = null) {
|
||||
let tab = document.getElementById("tabmail").currentTabInfo;
|
||||
let tabmail = document.getElementById("tabmail");
|
||||
let tab = tabmail.currentTabInfo;
|
||||
if (tab.chromeBrowser.contentDocument.readyState != "complete") {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
tab.chromeBrowser.contentWindow,
|
||||
|
@ -111,22 +112,23 @@ async function check3PaneState(folderPaneOpen = null, messagePaneOpen = null) {
|
|||
);
|
||||
}
|
||||
|
||||
let { paneLayout } = tabmail.currentAbout3Pane;
|
||||
if (folderPaneOpen !== null) {
|
||||
Assert.equal(
|
||||
tab.folderPaneVisible,
|
||||
paneLayout.folderPaneVisible,
|
||||
folderPaneOpen,
|
||||
"State of folder pane splitter is correct"
|
||||
);
|
||||
tab.folderPaneVisible = folderPaneOpen;
|
||||
paneLayout.folderPaneVisible = folderPaneOpen;
|
||||
}
|
||||
|
||||
if (messagePaneOpen !== null) {
|
||||
Assert.equal(
|
||||
tab.messagePaneVisible,
|
||||
paneLayout.messagePaneVisible,
|
||||
messagePaneOpen,
|
||||
"State of message pane splitter is correct"
|
||||
);
|
||||
tab.messagePaneVisible = messagePaneOpen;
|
||||
paneLayout.messagePaneVisible = messagePaneOpen;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,10 @@ add_setup(async function() {
|
|||
* menus, splitters, etc. are set up right.
|
||||
*/
|
||||
function assert_folder_pane_visible() {
|
||||
let tab = mc.window.document.getElementById("tabmail").currentTabInfo;
|
||||
let win = get_about_3pane();
|
||||
|
||||
Assert.equal(
|
||||
tab.folderPaneVisible,
|
||||
win.paneLayout.folderPaneVisible,
|
||||
true,
|
||||
"The tab does not think that the folder pane is visible, but it should!"
|
||||
);
|
||||
|
@ -70,11 +69,10 @@ function assert_folder_pane_visible() {
|
|||
* menus, splitters, etc. are set up right.
|
||||
*/
|
||||
function assert_folder_pane_hidden() {
|
||||
let tab = mc.window.document.getElementById("tabmail").currentTabInfo;
|
||||
let win = get_about_3pane();
|
||||
|
||||
Assert.equal(
|
||||
tab.folderPaneVisible,
|
||||
win.paneLayout.folderPaneVisible,
|
||||
false,
|
||||
"The tab thinks that the folder pane is visible, but it shouldn't!"
|
||||
);
|
||||
|
@ -205,7 +203,10 @@ add_task(async function test_folder_pane_persistence_generally_works() {
|
|||
if (iTab != 0) {
|
||||
await open_folder_in_new_tab(folder);
|
||||
}
|
||||
if (tabmail.currentTabInfo.folderPaneVisible != folderPaneVisible) {
|
||||
if (
|
||||
tabmail.currentAbout3Pane.paneLayout.folderPaneVisible !=
|
||||
folderPaneVisible
|
||||
) {
|
||||
toggle_folder_pane();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,6 +167,8 @@ add_task(async function test_message_pane_is_sticky() {
|
|||
add_task(async function test_message_pane_persistence_generally_works() {
|
||||
await be_in_folder(folder);
|
||||
|
||||
let tabmail = mc.window.document.getElementById("tabmail");
|
||||
|
||||
// helper to open tabs with the folder pane in the desired states (1 for
|
||||
// visible, 0 for hidden)
|
||||
async function openTabs(aConfig) {
|
||||
|
@ -175,8 +177,8 @@ add_task(async function test_message_pane_persistence_generally_works() {
|
|||
await open_folder_in_new_tab(folder);
|
||||
}
|
||||
if (
|
||||
mc.window.document.getElementById("tabmail").currentTabInfo
|
||||
.messagePaneVisible != messagePaneVisible
|
||||
tabmail.currentAbout3Pane.paneLayout.messagePaneVisible !=
|
||||
messagePaneVisible
|
||||
) {
|
||||
toggle_message_pane();
|
||||
}
|
||||
|
@ -185,7 +187,7 @@ add_task(async function test_message_pane_persistence_generally_works() {
|
|||
|
||||
// close everything but the first tab.
|
||||
function closeTabs() {
|
||||
while (mc.window.document.getElementById("tabmail").tabInfo.length > 1) {
|
||||
while (tabmail.tabInfo.length > 1) {
|
||||
close_tab(1);
|
||||
}
|
||||
}
|
||||
|
@ -195,18 +197,10 @@ add_task(async function test_message_pane_persistence_generally_works() {
|
|||
info("tab " + iTab);
|
||||
|
||||
await switch_tab(iTab);
|
||||
if (
|
||||
mc.window.document.getElementById("tabmail").currentAbout3Pane.document
|
||||
.readyState != "complete"
|
||||
) {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
mc.window.document.getElementById("tabmail").currentAbout3Pane,
|
||||
"load"
|
||||
);
|
||||
if (tabmail.currentAbout3Pane.document.readyState != "complete") {
|
||||
await BrowserTestUtils.waitForEvent(tabmail.currentAbout3Pane, "load");
|
||||
await new Promise(resolve =>
|
||||
mc.window.document
|
||||
.getElementById("tabmail")
|
||||
.currentAbout3Pane.setTimeout(resolve)
|
||||
tabmail.currentAbout3Pane.setTimeout(resolve)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -227,7 +221,7 @@ add_task(async function test_message_pane_persistence_generally_works() {
|
|||
for (let config of configs) {
|
||||
await openTabs(config);
|
||||
await verifyTabs(config); // make sure openTabs did its job right
|
||||
let state = mc.window.document.getElementById("tabmail").persistTabs();
|
||||
let state = tabmail.persistTabs();
|
||||
closeTabs();
|
||||
|
||||
Assert.equal(state.tabs[0].state.messagePaneVisible, config[0]);
|
||||
|
@ -240,7 +234,7 @@ add_task(async function test_message_pane_persistence_generally_works() {
|
|||
// to change things.
|
||||
toggle_message_pane();
|
||||
|
||||
mc.window.document.getElementById("tabmail").restoreTabs(state);
|
||||
tabmail.restoreTabs(state);
|
||||
await verifyTabs(config);
|
||||
closeTabs();
|
||||
|
||||
|
|
|
@ -1984,12 +1984,11 @@ var assert_message_not_in_view = assert_messages_not_in_view;
|
|||
* menus, splitters, etc. are set up right.
|
||||
*/
|
||||
function assert_message_pane_visible() {
|
||||
let tab = mc.window.document.getElementById("tabmail").currentTabInfo;
|
||||
let win = get_about_3pane();
|
||||
let messagePane = win.document.getElementById("messagePane");
|
||||
|
||||
Assert.equal(
|
||||
tab.messagePaneVisible,
|
||||
win.paneLayout.messagePaneVisible,
|
||||
true,
|
||||
"The tab does not think that the message pane is visible, but it should!"
|
||||
);
|
||||
|
@ -2017,12 +2016,11 @@ function assert_message_pane_visible() {
|
|||
* menus, splitters, etc. are set up right.
|
||||
*/
|
||||
function assert_message_pane_hidden() {
|
||||
let tab = mc.window.document.getElementById("tabmail").currentTabInfo;
|
||||
let win = get_about_3pane();
|
||||
let messagePane = win.document.getElementById("messagePane");
|
||||
|
||||
Assert.equal(
|
||||
tab.messagePaneVisible,
|
||||
win.paneLayout.messagePaneVisible,
|
||||
false,
|
||||
"The tab thinks that the message pane is visible, but it shouldn't!"
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче