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 --- .../extensions/test/xpcshell/test_install_icons.js | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js') diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js b/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js new file mode 100644 index 0000000000..af88b55959 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// use httpserver to find an available port +var gServer = new HttpServer(); +gServer.start(-1); +gPort = gServer.identity.primaryPort; + +var addon_url = "http://localhost:" + gPort + "/test.xpi"; +var icon32_url = "http://localhost:" + gPort + "/icon.png"; +var icon64_url = "http://localhost:" + gPort + "/icon64.png"; + +async function run_test() { + do_test_pending(); + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + await promiseStartupManager(); + + test_1(); +} + +async function test_1() { + let aInstall = await AddonManager.getInstallForURL(addon_url); + Assert.equal(aInstall.iconURL, null); + Assert.notEqual(aInstall.icons, null); + Assert.equal(aInstall.icons[32], undefined); + Assert.equal(aInstall.icons[64], undefined); + test_2(); +} + +async function test_2() { + let aInstall = await AddonManager.getInstallForURL(addon_url, { + icons: icon32_url, + }); + Assert.equal(aInstall.iconURL, icon32_url); + Assert.notEqual(aInstall.icons, null); + Assert.equal(aInstall.icons[32], icon32_url); + Assert.equal(aInstall.icons[64], undefined); + test_3(); +} + +async function test_3() { + let aInstall = await AddonManager.getInstallForURL(addon_url, { + icons: { 32: icon32_url }, + }); + Assert.equal(aInstall.iconURL, icon32_url); + Assert.notEqual(aInstall.icons, null); + Assert.equal(aInstall.icons[32], icon32_url); + Assert.equal(aInstall.icons[64], undefined); + test_4(); +} + +async function test_4() { + let aInstall = await AddonManager.getInstallForURL(addon_url, { + icons: { 32: icon32_url, 64: icon64_url }, + }); + Assert.equal(aInstall.iconURL, icon32_url); + Assert.notEqual(aInstall.icons, null); + Assert.equal(aInstall.icons[32], icon32_url); + Assert.equal(aInstall.icons[64], icon64_url); + executeSoon(do_test_finished); +} -- cgit v1.2.3