diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/addrbook/test/unit/test_photoURL.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mailnews/addrbook/test/unit/test_photoURL.js')
-rw-r--r-- | comm/mailnews/addrbook/test/unit/test_photoURL.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/comm/mailnews/addrbook/test/unit/test_photoURL.js b/comm/mailnews/addrbook/test/unit/test_photoURL.js new file mode 100644 index 0000000000..a6e7796264 --- /dev/null +++ b/comm/mailnews/addrbook/test/unit/test_photoURL.js @@ -0,0 +1,35 @@ +/* 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 { VCardUtils } = ChromeUtils.import("resource:///modules/VCardUtils.jsm"); + +/** + * Tests that vCard photo data is correctly translated into a URL for display. + */ +add_task(async function testVCardPhotoURL() { + let jpegPrefix = "data:image/jpeg;base64,/9j/4AAQSkZJRgABA"; + let pngPrefix = "data:image/png;base64,iVBORw0KGgoAAAANSU"; + + for (let [fileName, expectedURL] of [ + // Version 3, binary data, binary value type + ["v3-binary-jpeg.vcf", jpegPrefix], + ["v3-binary-png.vcf", pngPrefix], + // Version 3, URI data, binary value type (mismatch) + ["v3-uri-binary-jpeg.vcf", jpegPrefix], + ["v3-uri-binary-png.vcf", pngPrefix], + // Version 3, URI data, URI value type + ["v3-uri-uri-jpeg.vcf", jpegPrefix], + ["v3-uri-uri-png.vcf", pngPrefix], + // Version 4, URI data, URI value type + ["v4-uri-jpeg.vcf", jpegPrefix], + ["v4-uri-png.vcf", pngPrefix], + ]) { + info(`testing ${fileName}`); + let file = do_get_file(`data/${fileName}`); + let vCard = await IOUtils.readUTF8(file.path); + let card = VCardUtils.vCardToAbCard(vCard); + + Assert.equal(card.photoURL.substring(0, 40), expectedURL); + } +}); |