Bug 1508415 - Convert some remaining cases where MailServices.jsm and Services.jsm can be used in Thunderbird JS files. r=mkmelin

This commit is contained in:
aceman 2018-12-01 06:05:00 +01:00
Родитель 8280f273a6
Коммит 20e22daf68
23 изменённых файлов: 120 добавлений и 146 удалений

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

@ -22,6 +22,8 @@ ChromeUtils.defineModuleGetter(this, "Services", "resource://gre/modules/Service
* and nsDragAndDrop wrappers for more convenience
**/
ChromeUtils.import("resource://gre/modules/Services.jsm");
var nsTransferable = {
/**
* nsITransferable set (TransferData aTransferData) ;
@ -529,9 +531,7 @@ var nsDragAndDrop = {
return;
// aDraggedText is a URI, do the security check.
const nsIScriptSecurityManager = Ci.nsIScriptSecurityManager;
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(nsIScriptSecurityManager);
var secMan = Services.scriptSecurityManager;
if (!aDragSession)
aDragSession = this.mDragService.getCurrentSession();
@ -544,7 +544,7 @@ var nsDragAndDrop = {
try {
secMan.checkLoadURIStrWithPrincipal(principal, aDraggedText,
nsIScriptSecurityManager.STANDARD);
Ci.nsIScriptSecurityManager.STANDARD);
} catch (e) {
// Stop event propagation right here.
aEvent.stopPropagation();

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

@ -114,9 +114,8 @@ var kWindowsVersions = {
};
function set_windows_version(aVersion) {
let sysInfo = Cc["@mozilla.org/system-info;1"]
.getService(Ci.nsIWritablePropertyBag2);
sysInfo.setPropertyAsDouble("version", aVersion);
Services.sysinfo.QueryInterface(Ci.nsIWritablePropertyBag2)
.setPropertyAsDouble("version", aVersion);
}
/**

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

@ -24,7 +24,6 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyServiceGetters(this, {
gCategoryManager: ["@mozilla.org/categorymanager;1", "nsICategoryManager"],
gHandlerService: ["@mozilla.org/uriloader/handler-service;1", "nsIHandlerService"],
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
});

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

@ -28,9 +28,6 @@ var kRootURL = collector.addHttpResource('../cloudfile/html', '');
var kSettingsWithForm = kRootURL + 'settings-with-form.xhtml';
var gOldProviders = {};
XPCOMUtils.defineLazyServiceGetter(this, 'gCategoryMan',
'@mozilla.org/categorymanager;1',
'nsICategoryManager');
function setupModule(module) {
for (let lib of MODULE_REQUIRES) {
@ -38,23 +35,23 @@ function setupModule(module) {
}
// Save the old providers...
for (let entry of fixIterator(gCategoryMan.enumerateCategory(kCategory),
for (let entry of fixIterator(Services.catMan.enumerateCategory(kCategory),
Ci.nsISupportsCString)) {
let value = gCategoryMan.getCategoryEntry(kCategory, entry.data);
let value = Services.catMan.getCategoryEntry(kCategory, entry.data);
gOldProviders[entry] = value;
}
// Clear out the old entries
gCategoryMan.deleteCategory(kCategory);
Services.catMan.deleteCategory(kCategory);
}
function teardownModule(module) {
// Clear out any leftover entries.
gCategoryMan.deleteCategory(kCategory);
Services.catMan.deleteCategory(kCategory);
// Put the old entries back
for (let [key, value] of Object.entries(gOldProviders))
gCategoryMan.addCategoryEntry(kCategory, key, value, false, true);
Services.catMan.addCategoryEntry(kCategory, key, value, false, true);
}
/**

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

@ -166,8 +166,8 @@ var gMockCloudfileManager = {
this._mock_map[aID] = component;
gCategoryManager.addCategoryEntry("cloud-files", mockID,
mockContractID, false, true);
Services.catMan.addCategoryEntry("cloud-files", mockID,
mockContractID, false, true);
this._mock_map[aID].register();
},
@ -179,7 +179,7 @@ var gMockCloudfileManager = {
throw Error("No registered mock cloudfile provider with id = " +
aID);
gCategoryManager.deleteCategoryEntry("cloud-files", aID, false);
Services.catMan.deleteCategoryEntry("cloud-files", aID, false);
this._mock_map[aID].unregister();
delete this._mock_map[aID];
},
@ -193,8 +193,3 @@ var gMockCloudfileManager = {
XPCOMUtils.defineLazyServiceGetter(gMockCloudfileManager, "_uuidService",
"@mozilla.org/uuid-generator;1",
"nsIUUIDGenerator");
XPCOMUtils.defineLazyServiceGetter(this, "gCategoryManager",
"@mozilla.org/categorymanager;1",
"nsICategoryManager");

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

@ -469,14 +469,12 @@ function plugins_run_in_separate_processes(aController) {
}
function updateBlocklist(aController, aCallback) {
let blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
.getService(Ci.nsITimerCallback);
let observer = function() {
Services.obs.removeObserver(observer, "blocklist-updated");
aController.window.setTimeout(aCallback, 0);
};
Services.obs.addObserver(observer, "blocklist-updated");
blocklistNotifier.notify(null);
Services.blocklist.QueryInterface(Ci.nsITimerCallback).notify(null);
}
function setAndUpdateBlocklist(aController, aURL, aCallback) {

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

@ -1567,15 +1567,13 @@ var gAccountTree = {
panelsToKeep.push(panels[3]);
// extensions
let catMan = Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager);
const CATEGORY = "mailnews-accountmanager-extensions";
let catEnum = catMan.enumerateCategory(CATEGORY);
let catEnum = Services.catMan.enumerateCategory(CATEGORY);
while (catEnum.hasMoreElements()) {
let entryName = null;
try {
entryName = catEnum.getNext().QueryInterface(Ci.nsISupportsCString).data;
let svc = Cc[catMan.getCategoryEntry(CATEGORY, entryName)]
let svc = Cc[Services.catMan.getCategoryEntry(CATEGORY, entryName)]
.getService(Ci.nsIMsgAccountManagerExtension);
if (svc.showPanel(server)) {
let bundleName = "chrome://" + svc.chromePackageName +

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

@ -41,6 +41,7 @@ var okCallback = null;
*/
ChromeUtils.import("resource:///modules/MailServices.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
var contentWindow;

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

@ -433,10 +433,8 @@ function folderPickerChange(aEvent)
// We need to convert that from MUTF-7 to Unicode.
var manager = Cc['@mozilla.org/charset-converter-manager;1']
.getService(Ci.nsICharsetConverterManager);
var util = Cc["@mozilla.org/network/util;1"]
.getService(Ci.nsINetUtil);
var trashUnicode = manager.mutf7ToUnicode(
util.unescapeString(folderPath, Ci.nsINetUtil.ESCAPE_URL_PATH));
Services.netUtils.unescapeString(folderPath, Ci.nsINetUtil.ESCAPE_URL_PATH));
// Set the value to be persisted.
document.getElementById("imap.trashFolderName")

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

@ -76,8 +76,7 @@ function setupWizardPanels() {
setPageData(pageData, "server", "hostname", "localhost");
setPageData(pageData, "server", "port", "");
} else if (pages == "rss") {
let accountName = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
let accountName = Services.strings
.createBundle("chrome://messenger-newsblog/locale/newsblog.properties")
.GetStringFromName("feeds-accountname");
SetCurrentAccountData({

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

@ -38,12 +38,10 @@ var gOriginalOffline;
function placeAccountName(aServer) {
gOriginalOffline = Services.io.offline;
let bundle = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
let bundle = Services.strings
.createBundle("chrome://messenger/locale/converterDialog.properties");
let brandShortName = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
let brandShortName = Services.strings
.createBundle("chrome://branding/locale/brand.properties")
.GetStringFromName("brandShortName");
@ -168,8 +166,7 @@ function startContinue(aSelectedStoreType, aResponse) {
gResponse = aResponse;
gFolder = gServer.rootFolder.filePath;
let bundle = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
let bundle = Services.strings
.createBundle("chrome://messenger/locale/converterDialog.properties");
document.getElementById("progress").addEventListener("progress", function(e) {

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

@ -92,9 +92,7 @@ OAuth2Module.prototype = {
},
get refreshToken() {
let loginMgr = Cc["@mozilla.org/login-manager;1"]
.getService(Ci.nsILoginManager);
let logins = loginMgr.findLogins({}, this._loginUrl, null, this._scope);
let logins = Services.logins.findLogins({}, this._loginUrl, null, this._scope);
for (let login of logins) {
if (login.username == this._username)
return login.password;
@ -102,22 +100,19 @@ OAuth2Module.prototype = {
return '';
},
set refreshToken(token) {
let loginMgr = Cc["@mozilla.org/login-manager;1"]
.getService(Ci.nsILoginManager);
// Check if we already have a login with this username, and modify the
// password on that, if we do.
let logins = loginMgr.findLogins({}, this._loginUrl, null, this._scope);
let logins = Services.logins.findLogins({}, this._loginUrl, null, this._scope);
for (let login of logins) {
if (login.username == this._username) {
if (token) {
let propBag = Cc["@mozilla.org/hash-property-bag;1"].
createInstance(Ci.nsIWritablePropertyBag);
propBag.setProperty("password", token);
loginMgr.modifyLogin(login, propBag);
Services.logins.modifyLogin(login, propBag);
}
else
loginMgr.removeLogin(login);
Services.logins.removeLogin(login);
return token;
}
}
@ -128,7 +123,7 @@ OAuth2Module.prototype = {
.createInstance(Ci.nsILoginInfo);
login.init(this._loginUrl, null, this._scope, this._username, token,
'', '');
loginMgr.addLogin(login);
Services.logins.addLogin(login);
}
return token;
},

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

@ -31,7 +31,7 @@ var gLocalTrashFolder;
// storeIn takes a string containing the variable to store the new folder in
function addFolder(parent, folderName, storeIn)
{
gExpectedEvents = [[gMFNService.folderAdded, parent, folderName, storeIn]];
gExpectedEvents = [[MailServices.mfn.folderAdded, parent, folderName, storeIn]];
// We won't receive a copy listener notification for this
gCurrStatus |= kStatus.onStopCopyDone;
parent.createSubfolder(folderName, null);
@ -49,8 +49,8 @@ function addFolder(parent, folderName, storeIn)
function copyFileMessage(file, destFolder, isDraftOrTemplate)
{
copyListener.mFolderStoredIn = destFolder;
gExpectedEvents = [[gMFNService.msgAdded, gHdrsReceived],
[gMFNService.msgsClassified, gHdrsReceived, false, false]];
gExpectedEvents = [[MailServices.mfn.msgAdded, gHdrsReceived],
[MailServices.mfn.msgsClassified, gHdrsReceived, false, false]];
gCopyService.CopyFileMessage(file, destFolder, null, isDraftOrTemplate, 0, "",
copyListener, null);
gCurrStatus |= kStatus.functionCallDone;
@ -65,7 +65,7 @@ function copyMessages(items, isMove, srcFolder, destFolder)
array.appendElement(item);
});
gExpectedEvents = [
[gMFNService.msgsMoveCopyCompleted, isMove, items, destFolder, true]];
[MailServices.mfn.msgsMoveCopyCompleted, isMove, items, destFolder, true]];
gCopyService.CopyMessages(srcFolder, array, destFolder, isMove, copyListener,
null, true);
gCurrStatus |= kStatus.functionCallDone;
@ -79,7 +79,7 @@ function copyFolders(items, isMove, destFolder)
items.forEach(function (item) {
array.appendElement(item);
});
gExpectedEvents = [[gMFNService.folderMoveCopyCompleted, isMove, items, destFolder]];
gExpectedEvents = [[MailServices.mfn.folderMoveCopyCompleted, isMove, items, destFolder]];
gCopyService.CopyFolders(array, destFolder, isMove, copyListener, null);
gCurrStatus |= kStatus.functionCallDone;
if (gCurrStatus == kStatus.everythingDone)
@ -99,11 +99,11 @@ function deleteMessages(srcFolder, items, deleteStorage, isMove)
{
// We won't be getting any OnStopCopy notification in this case
gCurrStatus = kStatus.onStopCopyDone;
gExpectedEvents = [[gMFNService.msgsDeleted, items]];
gExpectedEvents = [[MailServices.mfn.msgsDeleted, items]];
}
else
// We have to be getting a move notification, even if isMove is false
gExpectedEvents = [[gMFNService.msgsMoveCopyCompleted, true, items,
gExpectedEvents = [[MailServices.mfn.msgsMoveCopyCompleted, true, items,
gLocalTrashFolder, true]];
srcFolder.deleteMessages(array, null, deleteStorage, isMove, copyListener, true);
@ -114,7 +114,7 @@ function deleteMessages(srcFolder, items, deleteStorage, isMove)
function renameFolder(folder, newName)
{
gExpectedEvents = [[gMFNService.folderRenamed, [folder], newName]];
gExpectedEvents = [[MailServices.mfn.folderRenamed, [folder], newName]];
gCurrStatus = kStatus.onStopCopyDone;
folder.rename(newName, null);
gCurrStatus |= kStatus.functionCallDone;
@ -135,11 +135,13 @@ function deleteFolder(folder, child)
// a folderMoveCopyCompleted.
if (gLocalTrashFolder.isAncestorOf(folder))
if (child)
gExpectedEvents = [[gMFNService.folderDeleted, [child]], [gMFNService.folderDeleted, [folder]]];
gExpectedEvents = [[MailServices.mfn.folderDeleted, [child]],
[MailServices.mfn.folderDeleted, [folder]]];
else
gExpectedEvents = [[gMFNService.folderDeleted, [folder]]];
gExpectedEvents = [[MailServices.mfn.folderDeleted, [folder]]];
else
gExpectedEvents = [[gMFNService.folderMoveCopyCompleted, true, [folder], gLocalTrashFolder]];
gExpectedEvents = [[MailServices.mfn.folderMoveCopyCompleted, true,
[folder], gLocalTrashFolder]];
folder.parent.deleteSubFolders(array, null);
gCurrStatus |= kStatus.functionCallDone;
@ -149,8 +151,8 @@ function deleteFolder(folder, child)
function compactFolder(folder)
{
gExpectedEvents = [[gMFNService.itemEvent, folder, "FolderCompactStart"],
[gMFNService.itemEvent, folder, "FolderCompactFinish"]];
gExpectedEvents = [[MailServices.mfn.itemEvent, folder, "FolderCompactStart"],
[MailServices.mfn.itemEvent, folder, "FolderCompactFinish"]];
// We won't receive a copy listener notification for this
gCurrStatus |= kStatus.onStopCopyDone;
folder.compact(null, null);
@ -307,7 +309,7 @@ var gTestArray =
function run_test()
{
// Add a listener.
gMFNService.addListener(gMFListener, allTestedEvents);
MailServices.mfn.addListener(gMFListener, allTestedEvents);
localAccountUtils.loadLocalMailAccount();
@ -346,7 +348,7 @@ function doTest(test)
{
gHdrsReceived = null;
gMsgHdrs = null;
gMFNService.removeListener(gMFListener);
MailServices.mfn.removeListener(gMFListener);
do_test_finished(); // for the one in run_test()
}
}

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

@ -12,6 +12,12 @@
<binding id="glodacomplete-rich-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-rich-result-popup">
<implementation implements="nsIAutoCompletePopup">
<constructor>
<![CDATA[
ChromeUtils.import("resource://gre/modules/Services.jsm");
]]>
</constructor>
<method name="_appendCurrentResult">
<body>
<![CDATA[
@ -29,9 +35,8 @@
var trimmedSearchString = controller.searchString.trim();
// Unescape the URI spec for showing as an entry in the popup
let url = Cc["@mozilla.org/intl/texttosuburi;1"]
.getService(Ci.nsITextToSubURI)
.unEscapeURIForUI("UTF-8", controller.getValueAt(this._currentIndex));
let url = Services.textToSubURI
.unEscapeURIForUI("UTF-8", controller.getValueAt(this._currentIndex));
// Unlike our superclass, we create nodes every time because we have
// heterogeneous results and we cannot rely on the XBL bindings to

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

@ -4,9 +4,9 @@
// Tests corpus management functions using nsIMsgCorpus
var msgCorpus =
Cc["@mozilla.org/messenger/filter-plugin;1?name=bayesianfilter"]
.getService(Ci.nsIMsgCorpus);
ChromeUtils.import("resource:///modules/MailServices.jsm");
var msgCorpus = MailServices.junk.QueryInterface(Ci.nsIMsgCorpus);
// tokens found in the test corpus file. trait 1001 was trained with
// 2 messages, and trait 1003 with 1.

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

@ -41,7 +41,7 @@ var gMsgWindow = Cc["@mozilla.org/messenger/msgwindow;1"]
function addFolder(parent, folderName, storeIn)
{
gExpectedEvents = [[gMFNService.folderAdded, parent, folderName, storeIn]];
gExpectedEvents = [[MailServices.mfn.folderAdded, parent, folderName, storeIn]];
// No copy listener notification for this
gCurrStatus |= kStatus.onStopCopyDone;
parent.createSubfolder(folderName, null);
@ -66,8 +66,8 @@ function copyFileMessage(file, messageId, destFolder)
// copyListener.mMessageId = messageId;
// Instead store the message id in gExpectedEvents, so we can match that up
gExpectedEvents = [[gMFNService.msgAdded, {expectedMessageId: messageId}],
[gMFNService.msgsClassified, [messageId], false, false]];
gExpectedEvents = [[MailServices.mfn.msgAdded, {expectedMessageId: messageId}],
[MailServices.mfn.msgsClassified, [messageId], false, false]];
destFolder.updateFolder(null);
gCopyService.CopyFileMessage(file, destFolder, null, true, 0, "", copyListener, null);
gCurrStatus |= kStatus.functionCallDone;
@ -103,9 +103,9 @@ function addMessagesToServer(messages, mailbox, localFolder)
// Create the imapMessage and store it on the mailbox.
mailbox.addMessage(new imapMessage(URI.spec, mailbox.uidnext++, []));
// We can't get the headers again, so just pass on the message id
gExpectedEvents.push([gMFNService.msgAdded, {expectedMessageId: message.messageId}]);
gExpectedEvents.push([MailServices.mfn.msgAdded, {expectedMessageId: message.messageId}]);
});
gExpectedEvents.push([gMFNService.msgsClassified,
gExpectedEvents.push([MailServices.mfn.msgsClassified,
messages.map(hdr => hdr.messageId),
false, false]);
@ -123,19 +123,19 @@ function copyMessages(messages, isMove, srcFolder, destFolder)
{
array.appendElement(message);
});
gExpectedEvents = [[gMFNService.msgsMoveCopyCompleted, isMove, messages, destFolder, true]];
gExpectedEvents = [[MailServices.mfn.msgsMoveCopyCompleted, isMove, messages, destFolder, true]];
// We'll also get the msgAdded events when we go and update the destination
// folder
messages.forEach(function (message)
{
// We can't use the headers directly, because the notifications we'll
// receive are for message headers in the destination folder
gExpectedEvents.push([gMFNService.msgKeyChanged,
gExpectedEvents.push([MailServices.mfn.msgKeyChanged,
{expectedMessageId: message.messageId}]);
gExpectedEvents.push([gMFNService.msgAdded,
gExpectedEvents.push([MailServices.mfn.msgAdded,
{expectedMessageId: message.messageId}]);
});
gExpectedEvents.push([gMFNService.msgsClassified,
gExpectedEvents.push([MailServices.mfn.msgsClassified,
messages.map(hdr => hdr.messageId),
false, false]);
gCopyService.CopyMessages(srcFolder, array, destFolder, isMove, copyListener, gMsgWindow, true);
@ -192,7 +192,7 @@ function run_test()
gTest = 0;
// Add a listener.
gMFNService.addListener(gMFListener, allTestedEvents);
MailServices.mfn.addListener(gMFListener, allTestedEvents);
gIMAPDaemon = new imapDaemon();
gServer = makeServer(gIMAPDaemon, "");
@ -232,7 +232,7 @@ function run_test()
// We get these notifications on initial discovery
gRootFolder = gIMAPIncomingServer.rootFolder;
gIMAPInbox = gRootFolder.getChildNamed("Inbox");
gExpectedEvents = [[gMFNService.folderAdded, gRootFolder, "Trash",
gExpectedEvents = [[MailServices.mfn.folderAdded, gRootFolder, "Trash",
"gIMAPTrashFolder"]];
gCurrStatus |= kStatus.onStopCopyDone | kStatus.functionCallDone;
@ -261,7 +261,7 @@ function doTest(test)
}
else
{
gMFNService.removeListener(gMFListener);
MailServices.mfn.removeListener(gMFListener);
// Cleanup, null out everything, close all cached connections and stop the
// server
gRootFolder = null;

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

@ -1,8 +1,10 @@
ChromeUtils.import("resource:///modules/MailServices.jsm");
function run_test()
{
// Due to the import code using nsIAbManager off the main thread, we need
// to ensure that it is initialized before we start the main test.
let abMgr = Cc["@mozilla.org/abmanager;1"].getService(Ci.nsIAbManager);
let abMgr = MailServices.ab;
let file = do_get_file("resources/becky/addressbooks");
let helper = new AbImportHelper(file, "Becky!", "addressbooks",

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

@ -8,7 +8,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
function run_test() {
let testFolderName = "";
let OSname = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).getProperty("name");
let OSname = Services.sysinfo.getProperty("name");
if (OSname == "Windows_NT") {
// On Windows test file with ' ' in the name.
testFolderName = "bugmail 1";

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

@ -63,19 +63,16 @@ Services.obs.addObserver(function (subject, topic, data) {
subject = subject.QueryInterface(Ci.nsISupportsCString)
.data;
if (data == CATEGORY_NAME) {
let url = catman.getCategoryEntry(CATEGORY_NAME, subject);
let url = Services.catMan.getCategoryEntry(CATEGORY_NAME, subject);
Services.scriptloader.loadSubScript(url, {}, "UTF-8");
}
}, "xpcom-category-entry-added");
var catman = Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager);
var entries = catman.enumerateCategory(CATEGORY_NAME);
var entries = Services.catMan.enumerateCategory(CATEGORY_NAME);
while (entries.hasMoreElements()) {
let string = entries.getNext()
.QueryInterface(Ci.nsISupportsCString)
.data;
let url = catman.getCategoryEntry(CATEGORY_NAME, string);
let url = Services.catMan.getCategoryEntry(CATEGORY_NAME, string);
Services.scriptloader.loadSubScript(url, {}, "UTF-8");
}

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

@ -56,9 +56,8 @@ add_task(async function check_custom_header() {
}
Services.obs.addObserver(observer, "xpcom-category-entry-added");
});
Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager)
.addCategoryEntry("custom-mime-encoder", "X-Unusual", url, false, true);
Services.catMan
.addCategoryEntry("custom-mime-encoder", "X-Unusual", url, false, true);
// The category manager doesn't fire until a later timestep.
await promise;
let headers = new StructuredHeaders();

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

@ -6,6 +6,7 @@
* - Downloading a single message and checking content in stream is correct.
*/
ChromeUtils.import("resource:///modules/MailServices.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// The basic daemon to use for testing nntpd.js implementations
@ -82,8 +83,7 @@ function run_test() {
var messageUri = folder.getUriForMsg(message);
var nntpService = Cc["@mozilla.org/messenger/nntpservice;1"]
.getService(Ci.nsIMsgMessageService);
var nntpService = MailServices.nntp.QueryInterface(Ci.nsIMsgMessageService);
do_test_pending();

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

@ -1,6 +1,7 @@
// Tests nsINntpUrl parsing.
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource:///modules/MailServices.jsm");
var localserver;
var tests = [
@ -141,8 +142,7 @@ var invalid_uris = [
function run_test() {
// We're not running the server, just setting it up
localserver = setupLocalServer(119);
let nntpService = Cc["@mozilla.org/messenger/nntpservice;1"]
.getService(Ci.nsIProtocolHandler);
let nntpService = MailServices.nntp.QueryInterface(Ci.nsIProtocolHandler);
for (let test of tests) {
dump("Checking URL " + test.uri + "\n");
let url = nntpService.newURI(test.uri);

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

@ -1,23 +1,16 @@
ChromeUtils.import("resource:///modules/MailServices.jsm");
var nsIMsgDBHdr = Ci.nsIMsgDBHdr;
var nsIArray = Ci.nsIArray;
var nsIMsgFolder = Ci.nsIMsgFolder;
var gMFNService = Cc["@mozilla.org/messenger/msgnotificationservice;1"]
.getService(Ci.nsIMsgFolderNotificationService);
var allTestedEvents =
gMFNService.msgAdded |
gMFNService.msgsClassified |
gMFNService.msgsDeleted |
gMFNService.msgsMoveCopyCompleted |
gMFNService.msgKeyChanged |
gMFNService.folderAdded |
gMFNService.folderDeleted |
gMFNService.folderMoveCopyCompleted |
gMFNService.folderRenamed |
gMFNService.itemEvent;
MailServices.mfn.msgAdded |
MailServices.mfn.msgsClassified |
MailServices.mfn.msgsDeleted |
MailServices.mfn.msgsMoveCopyCompleted |
MailServices.mfn.msgKeyChanged |
MailServices.mfn.folderAdded |
MailServices.mfn.folderDeleted |
MailServices.mfn.folderMoveCopyCompleted |
MailServices.mfn.folderRenamed |
MailServices.mfn.itemEvent;
var gCopyService = MailServices.copy;
@ -48,7 +41,7 @@ var gMFListener =
{
msgAdded: function(aMsg)
{
verify([gMFNService.msgAdded, aMsg]);
verify([MailServices.mfn.msgAdded, aMsg]);
// We might not actually have a header in gHdrsReceived in the IMAP case,
// so use the aMsg we got instead
gMsgHdrs.push({hdr: aMsg, ID: aMsg.messageId});
@ -58,7 +51,7 @@ var gMFListener =
if (gCurrStatus == kStatus.everythingDone)
resetStatusAndProceed();
}
else if (gExpectedEvents[0][0] == gMFNService.msgsClassified)
else if (gExpectedEvents[0][0] == MailServices.mfn.msgsClassified)
{
// XXX this is a hack to deal with limitations of the classification logic
// and the new list. We want to issue a call to clear the list once all
@ -72,7 +65,7 @@ var gMFListener =
msgsClassified: function(aMsgs, aJunkProcessed, aTraitProcessed)
{
dump("classified id: " + aMsgs.queryElementAt(0, Ci.nsIMsgDBHdr).messageId + "\n");
verify([gMFNService.msgsClassified, aMsgs, aJunkProcessed,
verify([MailServices.mfn.msgsClassified, aMsgs, aJunkProcessed,
aTraitProcessed]);
if (gExpectedEvents.length == 0)
{
@ -84,7 +77,7 @@ var gMFListener =
msgsDeleted: function(aMsgs)
{
verify([gMFNService.msgsDeleted, aMsgs]);
verify([MailServices.mfn.msgsDeleted, aMsgs]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -95,7 +88,7 @@ var gMFListener =
msgsMoveCopyCompleted: function(aMove, aSrcMsgs, aDestFolder, aDestMsgs)
{
verify([gMFNService.msgsMoveCopyCompleted, aMove, aSrcMsgs, aDestFolder,
verify([MailServices.mfn.msgsMoveCopyCompleted, aMove, aSrcMsgs, aDestFolder,
aDestMsgs]);
if (gExpectedEvents.length == 0)
{
@ -107,7 +100,7 @@ var gMFListener =
msgKeyChanged: function(aOldKey, aNewMsgHdr)
{
verify([gMFNService.msgKeyChanged, aOldKey, aNewMsgHdr]);
verify([MailServices.mfn.msgKeyChanged, aOldKey, aNewMsgHdr]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -118,7 +111,7 @@ var gMFListener =
folderAdded: function(aFolder)
{
verify([gMFNService.folderAdded, aFolder]);
verify([MailServices.mfn.folderAdded, aFolder]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -129,7 +122,7 @@ var gMFListener =
folderDeleted: function(aFolder)
{
verify([gMFNService.folderDeleted, aFolder]);
verify([MailServices.mfn.folderDeleted, aFolder]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -140,7 +133,7 @@ var gMFListener =
folderMoveCopyCompleted: function(aMove, aSrcFolder, aDestFolder)
{
verify([gMFNService.folderMoveCopyCompleted, aMove, aSrcFolder, aDestFolder]);
verify([MailServices.mfn.folderMoveCopyCompleted, aMove, aSrcFolder, aDestFolder]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -151,7 +144,7 @@ var gMFListener =
folderRenamed: function(aOrigFolder, aNewFolder)
{
verify([gMFNService.folderRenamed, aOrigFolder, aNewFolder]);
verify([MailServices.mfn.folderRenamed, aOrigFolder, aNewFolder]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -166,7 +159,7 @@ var gMFListener =
// empty...
Assert.equal(aBetterBeNull, null);
Assert.equal(aBetterBeEmpty, "");
verify([gMFNService.itemEvent, aFolder, aEvent]);
verify([MailServices.mfn.itemEvent, aFolder, aEvent]);
if (gExpectedEvents.length == 0)
{
gCurrStatus |= kStatus.notificationsDone;
@ -216,7 +209,7 @@ function resetStatusAndProceed()
function hasExactlyElements(array, elements)
{
// If an nsIArray (it could also be a single header or a folder)
if (elements instanceof nsIArray)
if (elements instanceof Ci.nsIArray)
{
var count = elements.length;
@ -228,13 +221,13 @@ function hasExactlyElements(array, elements)
// Check: query element, must be a header or folder and present in the array
var currElement;
try {
currElement = elements.queryElementAt(i, nsIMsgDBHdr);
currElement = elements.queryElementAt(i, Ci.nsIMsgDBHdr);
}
catch (e) {}
if (!currElement)
{
try {
currElement = elements.queryElementAt(i, nsIMsgFolder);
currElement = elements.queryElementAt(i, Ci.nsIMsgFolder);
}
catch (e) {}
}
@ -243,7 +236,7 @@ function hasExactlyElements(array, elements)
}
}
// If a single header or a folder
else if (elements instanceof nsIMsgDBHdr || elements instanceof nsIMsgFolder)
else if (elements instanceof Ci.nsIMsgDBHdr || elements instanceof Ci.nsIMsgFolder)
{
// Check: there should be only one element in the array.
Assert.equal(array.length, 1);
@ -271,7 +264,7 @@ function verify(event)
switch (eventType)
{
case gMFNService.msgAdded:
case MailServices.mfn.msgAdded:
// So for IMAP right now, we aren't able to get the actual nsIMsgDBHdr.
// Instead, we'll match up message ids as a (poor?) substitute.
if (expected[1].expectedMessageId)
@ -280,12 +273,12 @@ function verify(event)
break;
}
// If we do have a header, fall through to the case below
case gMFNService.msgsDeleted:
case gMFNService.folderDeleted:
case MailServices.mfn.msgsDeleted:
case MailServices.mfn.folderDeleted:
// Check: headers match/folder matches.
hasExactlyElements(expected[1], event[1]);
break;
case gMFNService.msgsClassified:
case MailServices.mfn.msgsClassified:
// In the IMAP case expected[1] is a list of mesage-id strings whereas in
// the local case (where we are copying from files), we actually have
// the headers.
@ -300,7 +293,7 @@ function verify(event)
let ignoreCount = event[1].length - expected[1].length;
for (let i = 0; i < expected[1].length; i++) {
let eventHeader = event[1].queryElementAt(i + ignoreCount,
nsIMsgDBHdr);
Ci.nsIMsgDBHdr);
Assert.equal(expected[1][i], eventHeader.messageId);
}
}
@ -312,11 +305,11 @@ function verify(event)
// aTraitProcessed: was the message processed for traits?
Assert.equal(expected[3], event[3]);
break;
case gMFNService.msgKeyChanged:
case MailServices.mfn.msgKeyChanged:
Assert.equal(expected[1].messageId, event[2].expectedMessageId);
break;
case gMFNService.msgsMoveCopyCompleted:
case gMFNService.folderMoveCopyCompleted:
case MailServices.mfn.msgsMoveCopyCompleted:
case MailServices.mfn.folderMoveCopyCompleted:
// Check: Move or copy as expected.
Assert.equal(expected[1], event[1]);
@ -326,7 +319,7 @@ function verify(event)
// Check: destination folder matches.
Assert.equal(expected[3], event[3]);
if (eventType == gMFNService.folderMoveCopyCompleted)
if (eventType == MailServices.mfn.folderMoveCopyCompleted)
break;
// Check: destination headers. We expect these for local and imap folders,
@ -335,12 +328,12 @@ function verify(event)
// we check that the message-id header values match up.
for (let iMsg = 0; iMsg < event[2].length; iMsg++)
{
let srcHdr = event[2].queryElementAt(iMsg, nsIMsgDBHdr);
let destHdr = event[4].queryElementAt(iMsg, nsIMsgDBHdr);
let srcHdr = event[2].queryElementAt(iMsg, Ci.nsIMsgDBHdr);
let destHdr = event[4].queryElementAt(iMsg, Ci.nsIMsgDBHdr);
Assert.equal(srcHdr.messageId, destHdr.messageId);
}
break;
case gMFNService.folderAdded:
case MailServices.mfn.folderAdded:
// Check: parent folder matches
Assert.equal(event[1].parent, expected[1]);
@ -352,14 +345,14 @@ function verify(event)
if (expected[3])
eval(expected[3] + "= event[1]");
break;
case gMFNService.folderRenamed:
case MailServices.mfn.folderRenamed:
// Check: source folder matches
hasExactlyElements(expected[1], event[1]);
// Check: destination folder name matches
Assert.equal(expected[2], event[2].prettyName);
break;
case gMFNService.itemEvent:
case MailServices.mfn.itemEvent:
// the event string should match
Assert.equal(expected[2], event[2]);
// and so should the folder we are talking about