From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mailnews/addrbook/test/unit/head.js | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 comm/mailnews/addrbook/test/unit/head.js (limited to 'comm/mailnews/addrbook/test/unit/head.js') diff --git a/comm/mailnews/addrbook/test/unit/head.js b/comm/mailnews/addrbook/test/unit/head.js new file mode 100644 index 0000000000..7a5155ea26 --- /dev/null +++ b/comm/mailnews/addrbook/test/unit/head.js @@ -0,0 +1,66 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ + +var { MailServices } = ChromeUtils.import( + "resource:///modules/MailServices.jsm" +); +var { TestUtils } = ChromeUtils.importESModule( + "resource://testing-common/TestUtils.sys.mjs" +); +var { XPCOMUtils } = ChromeUtils.importESModule( + "resource://gre/modules/XPCOMUtils.sys.mjs" +); + +// Ensure the profile directory is set up +do_get_profile(); + +// Import the required setup scripts. +/* import-globals-from ../../../test/resources/abSetup.js */ +load("../../../resources/abSetup.js"); + +registerCleanupFunction(function () { + load("../../../resources/mailShutdown.js"); +}); + +function promiseDirectoryRemoved(uri) { + let removePromise = TestUtils.topicObserved("addrbook-directory-deleted"); + MailServices.ab.deleteAddressBook(uri); + return removePromise; +} + +function acObserver() {} +acObserver.prototype = { + _search: null, + _result: null, + _resolve: null, + + onSearchResult(aSearch, aResult) { + this._search = aSearch; + this._result = aResult; + this._resolve(); + }, + + waitForResult() { + return new Promise(resolve => { + this._resolve = resolve; + }); + }, +}; + +function formatVCard(strings, ...values) { + let arr = []; + for (let str of strings) { + arr.push(str); + arr.push(values.shift()); + } + let lines = arr.join("").split("\n"); + let indent = lines[1].length - lines[1].trimLeft().length; + let outLines = []; + for (let line of lines) { + if (line.length > 0) { + outLines.push(line.substring(indent) + "\r\n"); + } + } + return outLines.join(""); +} -- cgit v1.2.3