# HG changeset patch # User aceman # Date 1537969860 -7200 # Node ID 60dfc2e2e18c5de53cd2ba530d817707a70c5ba6 # Parent 7efd133a8d3ee5a3662ad34563ad42684e277d33 Bug 1493513 - clean up migration of UI features. r=jorgk,mkmelin diff --git a/mail/app/profile/all-thunderbird.js b/mail/app/profile/all-thunderbird.js --- a/mail/app/profile/all-thunderbird.js +++ b/mail/app/profile/all-thunderbird.js @@ -282,16 +282,18 @@ pref("mail.close_message_window.on_delet // Number of lines of To/CC/BCC address headers to show before "more" // truncates the list. pref("mailnews.headers.show_n_lines_before_more", 1); // We want to keep track of what items are appropriate in // XULStore.json. We use versioning to scrub out the things // that have become obsolete. +// The value will always be set by startup code and must not be changed +// here. A value of 0 means a new profile. pref("mail.ui-rdf.version", 0); ///////////////////////////////////////////////////////////////// // Overrides of the core mailnews.js and composer.js prefs ///////////////////////////////////////////////////////////////// pref("mail.showCondensedAddresses", true); // show the friendly display name for people I know pref("mailnews.attachments.display.start_expanded", false); diff --git a/mail/base/modules/mailMigrator.js b/mail/base/modules/mailMigrator.js --- a/mail/base/modules/mailMigrator.js +++ b/mail/base/modules/mailMigrator.js @@ -107,38 +107,34 @@ var MailMigrator = { currentUIVersion = Services.prefs.getIntPref(UI_VERSION_PREF); } catch(ex) {} if (currentUIVersion >= UI_VERSION) return; let xulStore = Cc["@mozilla.org/xul/xulstore;1"].getService(Ci.nsIXULStore); + let newProfile = (currentUIVersion == 0); + if (newProfile) { + // Collapse the main menu by default if the override pref + // "mail.main_menu.collapse_by_default" is set to true. + if (Services.prefs.getBoolPref("mail.main_menu.collapse_by_default")) { + xulStore.setValue(MESSENGER_DOCURL, "mail-toolbar-menubar2", "autohide", "true"); + } + + // Set to current version to skip all the migration below. + currentUIVersion = UI_VERSION; + } + try { // UI versions below 5 could only exist in an old profile with localstore.rdf // file used for the XUL store. Since TB55 this file is no longer read. // Since UI version 5, the xulstore.json file is being used, so we only // support those version here, see bug 1371898. - // However, there's a tiny left-over. For new profiles (running the entire - // migration) we need to autohide the menubar. - - // In UI version 5, we add the AppMenu button to the mail toolbar and - // collapse the main menu by default if the user has no accounts - // set up (and the override pref "mail.main_menu.collapse_by_default" - // is set to true). Checking for 0 accounts is a hack, because we can't - // think of any better way of determining whether this profile is new - // or not. - if (currentUIVersion < 5) { - if (Services.prefs.getBoolPref("mail.main_menu.collapse_by_default") && - MailServices.accounts.accounts.length == 0) { - xulStore.setValue(MESSENGER_DOCURL, "mail-toolbar-menubar2", "autohide", "true"); - } - } - // In UI version 6, we move the otherActionsButton button to the // header-view-toolbar. if (currentUIVersion < 6) { let cs = xulStore.getValue(MESSENGER_DOCURL, "header-view-toolbar", "currentset"); if (cs && !cs.includes("otherActionsButton")) { // Put the otherActionsButton button at the end. cs = cs + "," + "otherActionsButton"; xulStore.setValue(MESSENGER_DOCURL, "header-view-toolbar", "currentset", cs); @@ -181,18 +177,19 @@ var MailMigrator = { detector == "ruprob" || detector == "ukprob")) { // If the encoding detector pref value is not reachable from the UI, // reset to default (varies by localization). Services.prefs.clearUserPref("intl.charset.detector"); } } + // This one is needed also in all new profiles. // Add an expanded entry for All Address Books. - if (currentUIVersion < 10) { + if (currentUIVersion < 10 || newProfile) { const DIR_TREE_FILE = "directoryTree.json"; // If the file exists, read its contents, prepend the "All ABs" URI // and save it, else, just write the "All ABs" URI to the file. let data = IOUtils.loadFileToString(DIR_TREE_FILE); if (!data || data == "[]") { data = ""; } else if (data.length > 0) { diff --git a/mail/test/mozmill/folder-tree-modes/test-mode-switching.js b/mail/test/mozmill/folder-tree-modes/test-mode-switching.js --- a/mail/test/mozmill/folder-tree-modes/test-mode-switching.js +++ b/mail/test/mozmill/folder-tree-modes/test-mode-switching.js @@ -19,16 +19,17 @@ var unreadFolder; var favoriteFolder; var toggle_menu; var toggle_appmenu; var tree; var modeList_menu; var modeList_appmenu; var view_menu; var view_appmenu; +var menu_state; function setupModule(module) { for (let lib of MODULE_REQUIRES) { collector.getModule(lib).installInto(module); } rootFolder = inboxFolder.server.rootFolder; @@ -51,16 +52,18 @@ function setupModule(module) { view_menu = mc.eid("menu_View"); view_menupopup = mc.e("menu_View_Popup"); appmenu = mc.eid("button-appmenu"); appmenupopup = mc.e("appmenu-popup"); tree = mc.folderTreeView; select_no_folders(); + // Main menu is needed for this whole test file. + menu_state = toggle_main_menu(true); } /** * Check if both "Compact view" checkboxes in menu are of the expected state. * * @param aChecked Boolean whether checkbox should be checked or not. * @param aDisabled Optional boolean whether the menuitem should be disabled.. */ @@ -270,9 +273,10 @@ function test_toggling_modes() { subtest_switch_to_smart_folders(true); subtest_switch_to_all_folders(true); } function teardownModule() { tree.mode = "all"; inboxFolder.propagateDelete(unreadFolder, true, null); inboxFolder.propagateDelete(favoriteFolder, true, null); + toggle_main_menu(menu_state); } diff --git a/mail/test/mozmill/folder-widget/test-message-filters.js b/mail/test/mozmill/folder-widget/test-message-filters.js --- a/mail/test/mozmill/folder-widget/test-message-filters.js +++ b/mail/test/mozmill/folder-widget/test-message-filters.js @@ -89,28 +89,25 @@ function test_customize_toolbar_doesnt_d { be_in_folder(folderA); /** * Get the getAllNewMessages menu and check the number of items. */ function check_getAllNewMsgMenu() { wait_for_window_focused(mc.window); - mc.click(mc.eid("menu_File"), 5, 5); - wait_for_popup_to_open(mc.e("menu_FilePopup")); + mc.click(mc.eid("button-appmenu"), 5, 5); + let popups = mc.click_menus_in_sequence(mc.e("appmenu-popup"), + [ { id: "appmenu_File" }, + { id: "appmenu_getNewMsgFor" } ], true); - let menu = mc.eid("menu_getAllNewMsg"); - mc.click(menu, 5, 5); - wait_for_popup_to_open(mc.e("menu_getAllNewMsgPopup")); - - assert_equals(menu.node.itemCount, 5, + assert_equals(popups[popups.length - 1].children.length, 5, "Incorrect number of items for GetNewMessages before customization"); - close_popup(mc, mc.eid("menu_getAllNewMsgPopup")); - close_popup(mc, mc.eid("menu_FilePopup")); + mc.close_popup_sequence(popups); } check_getAllNewMsgMenu(); plan_for_new_window("mailnews:customizeToolbar"); // Open the customization dialog. mc.rightClick(mc.eid("mail-bar3")); mc.click(mc.eid("CustomizeMailToolbar")); diff --git a/mail/test/mozmill/message-window/test-autohide-menubar.js b/mail/test/mozmill/message-window/test-autohide-menubar.js --- a/mail/test/mozmill/message-window/test-autohide-menubar.js +++ b/mail/test/mozmill/message-window/test-autohide-menubar.js @@ -23,18 +23,17 @@ function setupModule(module) { abh.installInto(module); let ch = collector.getModule("compose-helpers"); ch.installInto(module); menuFolder = create_folder("menuFolder"); make_new_sets_in_folder(menuFolder, [{count: 1}]); // Make the menubar not autohide by default. - let menubar = mc.e("mail-toolbar-menubar2"); - menubar.setAttribute("autohide", false); + menuState = toggle_main_menu(true); } /** * Set the autohide attribute of the menubar. * * @param controller the mozmill controller for the window * @param elem the element to click on (usually the menubar) * @param hide true to hide, false otherwise @@ -103,8 +102,12 @@ test_autohidden_menubar_compose_window.E function test_autohidden_menubar_address_book() { let abc = open_address_book_window(); let menubar = abc.e("addrbook-toolbar-menubar2"); help_test_autohide(abc, menubar); } test_autohidden_menubar_address_book.EXCLUDED_PLATFORMS = ["darwin", "linux"]; + +function teardownModule() { + toggle_main_menu(menuState); +} diff --git a/mail/test/mozmill/override-main-menu-collapse/wrapper.py b/mail/test/mozmill/override-main-menu-collapse/wrapper.py --- a/mail/test/mozmill/override-main-menu-collapse/wrapper.py +++ b/mail/test/mozmill/override-main-menu-collapse/wrapper.py @@ -7,16 +7,18 @@ # any Mozmill tests. import os import shutil import sys # We don't want any accounts for these tests. NO_ACCOUNTS = True +# Do not force enable main menu bar, we'll set our own value in prefs.js. +DEFAULT_MENUBAR = True def on_profile_created(profiledir): """ On profile creation, this copies prefs.js from the current folder to profile_dir/preferences. This is a somewhat undocumented feature -- anything in profile_dir/preferences gets treated as a default pref, which is what we want here. """ diff --git a/mail/test/mozmill/runtest.py b/mail/test/mozmill/runtest.py --- a/mail/test/mozmill/runtest.py +++ b/mail/test/mozmill/runtest.py @@ -122,16 +122,22 @@ class ThunderTestProfile(mozprofile.Thun # are still serviced; they just should not result in any matches.) 'mailnews.database.global.logging.upstream': True, # Do not allow fonts to be upgraded 'mail.font.windows.version': 2, # No, we don't want to be prompted about Telemetry 'toolkit.telemetry.prompted': 999, } + menubar_preferences = { + # Many tests operate items in the main menu, so keep it shown + # until they are migrated to appmenu. + 'mail.main_menu.collapse_by_default': False, + } + # Dummied up local accounts to stop the account wizard account_preferences = { 'mail.account.account1.server' : "server1", 'mail.account.account2.identities' : "id1,id2", 'mail.account.account2.server' : "server2", 'mail.account.account3.server' : "server3", 'mail.accountmanager.accounts' : "account1,account2,account3", 'mail.accountmanager.defaultaccount' : "account2", @@ -177,16 +183,22 @@ class ThunderTestProfile(mozprofile.Thun 'messenger.accounts' : "account1", } def __init__(self, *args, **kwargs): kwargs['profile'] = self.get_profile_dir() super(ThunderTestProfile, self).__init__(*args, **kwargs) self.set_preferences(self.preferences) + if (wrapper is not None and hasattr(wrapper, "DEFAULT_MENUBAR") + and wrapper.DEFAULT_MENUBAR): + pass + else: + self.set_preferences(self.menubar_preferences) + if (wrapper is not None and hasattr(wrapper, "NO_ACCOUNTS") and wrapper.NO_ACCOUNTS): pass else: self.set_preferences(self.account_preferences) def get_profile_dir(self): diff --git a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js --- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js +++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js @@ -2818,16 +2818,29 @@ function assert_pane_layout(aLayout) { /** * Change that the current mail pane layout */ function set_pane_layout(aLayout) { Services.prefs.setIntPref("mail.pane_config.dynamic", aLayout); } +/** + * Toggle visibility of the Main menu bar. + * + * @param aEnabled {boolean} Whether the menu should be shown or not. + */ +function toggle_main_menu(aEnabled = true) { + let menubar = mc.e("mail-toolbar-menubar2"); + let state = menubar.getAttribute("autohide") != "true"; + menubar.setAttribute("autohide", !aEnabled); + mc.sleep(0); + return state; +} + /** exported from messageInjection */ var make_new_sets_in_folders; var make_new_sets_in_folder; var add_sets_to_folders; var delete_message_set; var make_folder_with_sets; var make_virtual_folder; var SyntheticPartLeaf; diff --git a/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js b/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js --- a/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js +++ b/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js @@ -25,17 +25,17 @@ function test_main_menu_collapsed() { observe: function(aSubject, aTopic, aData) { if (aTopic == "mail-startup-done") { done = true; } } }; Services.obs.addObserver(observer, "mail-startup-done"); - // Since no accounts were set up, and the account provisoner was disabled + // Since no accounts were set up, and the account provisioner was disabled // in prefs.js, the wizard will show up. Find it, and close it. This will // cause mail-startup-done to eventually be fired. let wizard = wait_for_existing_window("mail:autoconfig"); close_window(wizard); // Spin the event loop until mail-startup-done is fired. mc.waitFor(() => done); diff --git a/mail/test/mozmill/startup-firstrun/wrapper.py b/mail/test/mozmill/startup-firstrun/wrapper.py --- a/mail/test/mozmill/startup-firstrun/wrapper.py +++ b/mail/test/mozmill/startup-firstrun/wrapper.py @@ -7,16 +7,18 @@ # any Mozmill tests. import os import shutil import sys # We don't want any accounts for these tests. NO_ACCOUNTS = True +# Do not force enable main menu bar (keep the default). +DEFAULT_MENUBAR = True def on_profile_created(profiledir): """ On profile creation, this copies prefs.js from the current folder to profile_dir/preferences. This is a somewhat undocumented feature -- anything in profile_dir/preferences gets treated as a default pref, which is what we want here. """