Bug 499273 -- "Delete Mail Marked as Junk in Folder" action in Tools menu doesn't work. Fix all uses of gMsgFolderSelected, and add a couple of tests for junk commands. r+sr=bienvenu
This commit is contained in:
Родитель
0eb658c8b3
Коммит
21fc9b5250
|
@ -49,8 +49,6 @@ Components.utils.import("resource://gre/modules/iteratorUtils.jsm");
|
|||
//NOTE: gMessengerBundle and gBrandBundle must be defined and set
|
||||
// for this Overlay to work properly
|
||||
|
||||
var gMsgFolderSelected;
|
||||
|
||||
function UpdateMailToolbar(caller)
|
||||
{
|
||||
//dump("XXX update mail-toolbar " + caller + "\n");
|
||||
|
|
|
@ -1690,10 +1690,9 @@ let gFolderTreeController = {
|
|||
//xxx should pass the folder object
|
||||
function editVirtualCallback(aURI) {
|
||||
// we need to reload the folder if it is the currently loaded folder...
|
||||
if (gMsgFolderSelected && aURI == gMsgFolderSelected.URI) {
|
||||
gMsgFolderSelected = null;
|
||||
if (gFolderDisplay.displayedFolder &&
|
||||
aURI == gFolderDisplay.displayedFolder.URI)
|
||||
FolderPaneSelectionChange();
|
||||
}
|
||||
}
|
||||
window.openDialog("chrome://messenger/content/virtualFolderProperties.xul",
|
||||
"", "chrome,titlebar,modal,centerscreen",
|
||||
|
|
|
@ -122,7 +122,7 @@ function MailToolboxCustomizeDone(aEvent, customizePopupId)
|
|||
if (document.getElementById("folder-location-container"))
|
||||
{
|
||||
loadFolderViewForTree(gCurrentFolderView, document.getElementById('folderLocationPopup').tree);
|
||||
UpdateFolderLocationPicker(gMsgFolderSelected);
|
||||
UpdateFolderLocationPicker(gFolderDisplay.displayedFolder);
|
||||
}
|
||||
|
||||
gSearchInput = null;
|
||||
|
|
|
@ -1663,10 +1663,7 @@ function CreateToolbarTooltip(document, event)
|
|||
* The tab info objects (as tabmail's currentTabInfo/tabInfo fields contain)
|
||||
* have the following attributes specific to our implementation:
|
||||
*
|
||||
*
|
||||
* @property {string} uriToOpen
|
||||
* @property {nsIMsgFolder} msgSelectedFolder Preserves gMsgFolderSelected
|
||||
* global.
|
||||
* @property {nsIMsgDBView} dbView The database view to use with the thread tree
|
||||
* when this tab is displayed. The value will be assigned to the global
|
||||
* gDBView in the process.
|
||||
|
@ -3500,9 +3497,9 @@ function FeedSetContentView(val)
|
|||
try
|
||||
{
|
||||
var targetRes = getParentTargetForChildResource(
|
||||
gMsgFolderSelected.URI,
|
||||
gFolderDisplay.displayedFolder.URI,
|
||||
FZ_QUICKMODE,
|
||||
gMsgFolderSelected.server);
|
||||
gFolderDisplay.displayedFolder.server);
|
||||
}
|
||||
catch (ex) {};
|
||||
|
||||
|
|
|
@ -101,9 +101,9 @@ var folderListener = {
|
|||
OnItemPropertyChanged: function(item, property, oldValue, newValue) { },
|
||||
|
||||
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) {
|
||||
if (item == gMsgFolderSelected) {
|
||||
if (item == gFolderDisplay.displayedFolder) {
|
||||
if(property.toString() == "TotalMessages" || property.toString() == "TotalUnreadMessages") {
|
||||
UpdateStatusMessageCounts(gMsgFolderSelected);
|
||||
UpdateStatusMessageCounts(gFolderDisplay.displayedFolder);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -320,7 +320,7 @@ function ThreadPaneOnLoad()
|
|||
|
||||
function ThreadPaneSelectionChanged()
|
||||
{
|
||||
UpdateStatusMessageCounts(gMsgFolderSelected);
|
||||
UpdateStatusMessageCounts(gFolderDisplay.displayedFolder);
|
||||
GetThreadTree().view.selectionChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Thunderbird Mail Client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Messaging, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Siddharth Agarwal <sid.bugzilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var MODULE_NAME = 'test-junk-commands';
|
||||
|
||||
var RELATIVE_ROOT = '../shared-modules';
|
||||
var MODULE_REQUIRES = ['folder-display-helpers', 'junk-helpers'];
|
||||
|
||||
// One folder's enough
|
||||
var folder = null;
|
||||
|
||||
function setupModule(module) {
|
||||
let fdh = collector.getModule('folder-display-helpers');
|
||||
fdh.installInto(module);
|
||||
let jh = collector.getModule('junk-helpers');
|
||||
jh.installInto(module);
|
||||
|
||||
folder = create_folder("JunkCommandsA");
|
||||
make_new_sets_in_folder(folder, [{count: 30}]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of messages to mark as junk and expect to be deleted.
|
||||
*/
|
||||
const NUM_MESSAGES_TO_JUNK = 8;
|
||||
|
||||
/**
|
||||
* Helper to check whether a folder has the right number of messages.
|
||||
*
|
||||
* @param aFolder the folder to check
|
||||
* @param aNumMessages the number of messages the folder should contain.
|
||||
*/
|
||||
function _assert_folder_total_messages(aFolder, aNumMessages) {
|
||||
let curMessages = aFolder.getTotalMessages(false);
|
||||
if (curMessages != aNumMessages)
|
||||
throw new Error("The folder " + aFolder.prettiestName + " should have " +
|
||||
aNumMessages + " messages, but actually has " + curMessages +
|
||||
" messages.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting junk messages with no messages marked as junk.
|
||||
*/
|
||||
function test_delete_no_junk_messages() {
|
||||
let initialNumMessages = folder.getTotalMessages(false);
|
||||
be_in_folder(folder);
|
||||
select_none();
|
||||
delete_mail_marked_as_junk();
|
||||
// Check if we still have the same number of messages
|
||||
_assert_folder_total_messages(folder, initialNumMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting junk messages with some messages marked as junk.
|
||||
*/
|
||||
function test_delete_junk_messages() {
|
||||
let initialNumMessages = folder.getTotalMessages(false);
|
||||
be_in_folder(folder);
|
||||
select_click_row(1);
|
||||
let selectedMessages = select_shift_click_row(NUM_MESSAGES_TO_JUNK);
|
||||
// Mark these messages as junk
|
||||
mark_selected_messages_as_junk();
|
||||
// Now delete junk mail
|
||||
delete_mail_marked_as_junk();
|
||||
// Check that we have the right number of messages left
|
||||
_assert_folder_total_messages(folder,
|
||||
initialNumMessages - NUM_MESSAGES_TO_JUNK);
|
||||
// Check that none of the message keys exist any more
|
||||
let db = folder.getDBFolderInfoAndDB({});
|
||||
for each (let [, msgHdr] in Iterator(selectedMessages)) {
|
||||
let key = msgHdr.messageKey;
|
||||
if (db.ContainsKey(key))
|
||||
throw new Error("The database shouldn't contain key " + key +
|
||||
", but does.");
|
||||
}
|
||||
}
|
|
@ -70,6 +70,8 @@ class ThunderTestProfile(mozrunner.ThunderbirdProfile):
|
|||
# disable address books for undisclosed reasons
|
||||
'ldap_2.servers.osx.position': 0,
|
||||
'ldap_2.servers.oe.position': 0,
|
||||
# disable the first use junk dialog
|
||||
'mailnews.ui.junk.firstuse': False,
|
||||
# other unknown voodoo
|
||||
# -- dummied up local accounts to stop the account wizard
|
||||
'mail.account.account1.server' : "server1",
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Thunderbird Mail Client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Messaging, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Siddharth Agarwal <sid.bugzilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cu = Components.utils;
|
||||
|
||||
var elib = {};
|
||||
Cu.import('resource://mozmill/modules/elementslib.js', elib);
|
||||
var mozmill = {};
|
||||
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
|
||||
|
||||
const MODULE_NAME = 'junk-helpers';
|
||||
|
||||
const RELATIVE_ROOT = '../shared-modules';
|
||||
|
||||
// we need this for the main controller
|
||||
const MODULES_REQUIRES = ['folder-display-helpers'];
|
||||
|
||||
var folderDisplayHelper;
|
||||
var mc;
|
||||
|
||||
function setupModule() {
|
||||
folderDisplayHelper = collector.getModule('folder-display-helpers');
|
||||
mc = folderDisplayHelper.mc;
|
||||
}
|
||||
|
||||
function installInto(module) {
|
||||
setupModule();
|
||||
|
||||
// Now copy helper functions
|
||||
module.mark_selected_messages_as_junk = mark_selected_messages_as_junk;
|
||||
module.delete_mail_marked_as_junk = delete_mail_marked_as_junk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the selected messages as junk. This is done by pressing the J key.
|
||||
*
|
||||
* @param aController The controller in whose context to do this, defaults to
|
||||
* |mc| if omitted.
|
||||
*/
|
||||
function mark_selected_messages_as_junk(aController) {
|
||||
if (aController === undefined)
|
||||
aController = mc;
|
||||
aController.keypress(aController == mc ? mc.eThreadTree : null,
|
||||
"j", {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all mail marked as junk in the selected folder. This is done by
|
||||
* activating the menu option from the Tools menu.
|
||||
*
|
||||
* @param aController The controller in whose context to do this, defaults to
|
||||
* |mc| if omitted.
|
||||
*/
|
||||
function delete_mail_marked_as_junk(aController) {
|
||||
if (aController === undefined)
|
||||
aController = mc;
|
||||
// if something is loading, make sure it finishes loading...
|
||||
folderDisplayHelper.wait_for_message_display_completion(aController);
|
||||
folderDisplayHelper.plan_to_wait_for_folder_events(
|
||||
"DeleteOrMoveMsgCompleted", "DeleteOrMoveMsgFailed");
|
||||
aController.click(new elib.Elem(aController.menus.tasksMenu.deleteJunk));
|
||||
folderDisplayHelper.wait_for_folder_events();
|
||||
}
|
|
@ -48,7 +48,7 @@
|
|||
* messenger
|
||||
* gMessengerBundle
|
||||
* gDBView
|
||||
* gMsgFolderSelected
|
||||
* either gMsgFolderSelected or gFolderDisplay
|
||||
* MsgJunkMailInfo(aCheckFirstUse)
|
||||
* SetNextMessageAfterDelete()
|
||||
* pref
|
||||
|
@ -394,7 +394,9 @@ function deleteJunkInFolder()
|
|||
MsgJunkMailInfo(true);
|
||||
|
||||
// use direct folder commands if possible so we don't mess with the selection
|
||||
if ( !(gMsgFolderSelected.flags & Components.interfaces.nsMsgFolderFlags.Virtual) )
|
||||
let selectedFolder = ("gFolderDisplay" in window) ?
|
||||
gFolderDisplay.displayedFolder : gMsgFolderSelected;
|
||||
if ( !(selectedFolder.flags & Components.interfaces.nsMsgFolderFlags.Virtual) )
|
||||
{
|
||||
var junkMsgHdrs = Components.classes["@mozilla.org/array;1"]
|
||||
.createInstance(Components.interfaces.nsIMutableArray);
|
||||
|
|
Загрузка…
Ссылка в новой задаче