diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-upstream/125.0.1.tar.xz firefox-upstream/125.0.1.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js')
-rw-r--r-- | browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js b/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js deleted file mode 100644 index 3d83f473d5..0000000000 --- a/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js +++ /dev/null @@ -1,69 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -"use strict"; - -const { AboutWelcomeDefaults } = ChromeUtils.importESModule( - "resource:///modules/aboutwelcome/AboutWelcomeDefaults.sys.mjs" -); -const { sinon } = ChromeUtils.importESModule( - "resource://testing-common/Sinon.sys.mjs" -); -const { AttributionCode } = ChromeUtils.importESModule( - "resource:///modules/AttributionCode.sys.mjs" -); -const { AddonRepository } = ChromeUtils.importESModule( - "resource://gre/modules/addons/AddonRepository.sys.mjs" -); - -const TEST_ATTRIBUTION_DATA = { - source: "addons.mozilla.org", - medium: "referral", - campaign: "non-fx-button", - content: "rta:iridium%40particlecore.github.io", -}; - -add_task(async function test_handleAddonInfoNotFound() { - let sandbox = sinon.createSandbox(); - const stub = sandbox.stub(AttributionCode, "getAttrDataAsync").resolves(null); - let result = await AboutWelcomeDefaults.getAttributionContent(); - equal(stub.callCount, 1, "Call was made"); - equal(result, null, "No data is returned"); - - sandbox.restore(); -}); - -add_task(async function test_UAAttribution() { - let sandbox = sinon.createSandbox(); - const stub = sandbox - .stub(AttributionCode, "getAttrDataAsync") - .resolves({ ua: "test" }); - let result = await AboutWelcomeDefaults.getAttributionContent(); - equal(stub.callCount, 1, "Call was made"); - equal(result.template, undefined, "Template was not returned"); - equal(result.ua, "test", "UA was returned"); - - sandbox.restore(); -}); - -add_task(async function test_formatAttributionData() { - let sandbox = sinon.createSandbox(); - const TEST_ADDON_INFO = { - sourceURI: { scheme: "https", spec: "https://test.xpi" }, - name: "Test Add-on", - icons: { 64: "http://test.svg" }, - }; - sandbox - .stub(AttributionCode, "getAttrDataAsync") - .resolves(TEST_ATTRIBUTION_DATA); - sandbox.stub(AddonRepository, "getAddonsByIDs").resolves([TEST_ADDON_INFO]); - let result = await AboutWelcomeDefaults.getAttributionContent( - TEST_ATTRIBUTION_DATA - ); - equal(AddonRepository.getAddonsByIDs.callCount, 1, "Retrieve addon content"); - equal(result.template, "return_to_amo", "RTAMO template returned"); - equal(result.name, TEST_ADDON_INFO.name, "AddonInfo returned"); - - sandbox.restore(); -}); |