summaryrefslogtreecommitdiffstats
path: root/browser/components/search/test/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /browser/components/search/test/unit
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/search/test/unit')
-rw-r--r--browser/components/search/test/unit/domain_category_mappings_1a.json3
-rw-r--r--browser/components/search/test/unit/domain_category_mappings_1b.json3
-rw-r--r--browser/components/search/test/unit/domain_category_mappings_2a.json3
-rw-r--r--browser/components/search/test/unit/domain_category_mappings_2b.json3
-rw-r--r--browser/components/search/test/unit/test_search_telemetry_categorization_logic.js225
-rw-r--r--browser/components/search/test/unit/test_search_telemetry_categorization_process_domains.js89
-rw-r--r--browser/components/search/test/unit/test_search_telemetry_categorization_sync.js66
-rw-r--r--browser/components/search/test/unit/xpcshell.toml8
8 files changed, 175 insertions, 225 deletions
diff --git a/browser/components/search/test/unit/domain_category_mappings_1a.json b/browser/components/search/test/unit/domain_category_mappings_1a.json
deleted file mode 100644
index 51b18e12a7..0000000000
--- a/browser/components/search/test/unit/domain_category_mappings_1a.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Wrq9YDsieAMC3Y2DSY5Rcg==": [1, 100]
-}
diff --git a/browser/components/search/test/unit/domain_category_mappings_1b.json b/browser/components/search/test/unit/domain_category_mappings_1b.json
deleted file mode 100644
index 698ef45f1a..0000000000
--- a/browser/components/search/test/unit/domain_category_mappings_1b.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "G99y4E1rUMgqSMfk3TjMaQ==": [2, 90]
-}
diff --git a/browser/components/search/test/unit/domain_category_mappings_2a.json b/browser/components/search/test/unit/domain_category_mappings_2a.json
deleted file mode 100644
index 08db2fa8c2..0000000000
--- a/browser/components/search/test/unit/domain_category_mappings_2a.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Wrq9YDsieAMC3Y2DSY5Rcg==": [1, 80]
-}
diff --git a/browser/components/search/test/unit/domain_category_mappings_2b.json b/browser/components/search/test/unit/domain_category_mappings_2b.json
deleted file mode 100644
index dec2d130c1..0000000000
--- a/browser/components/search/test/unit/domain_category_mappings_2b.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "G99y4E1rUMgqSMfk3TjMaQ==": [2, 50, 4, 80]
-}
diff --git a/browser/components/search/test/unit/test_search_telemetry_categorization_logic.js b/browser/components/search/test/unit/test_search_telemetry_categorization_logic.js
index 947a7aae46..44b9147c50 100644
--- a/browser/components/search/test/unit/test_search_telemetry_categorization_logic.js
+++ b/browser/components/search/test/unit/test_search_telemetry_categorization_logic.js
@@ -15,90 +15,111 @@ ChromeUtils.defineESModuleGetters(this, {
SearchSERPTelemetryUtils: "resource:///modules/SearchSERPTelemetry.sys.mjs",
});
-const TEST_DOMAIN_TO_CATEGORIES_MAP_SIMPLE = {
- "byVQ4ej7T7s2xf/cPqgMyw==": [2, 90],
- "1TEnSjgNCuobI6olZinMiQ==": [2, 95],
- "/Bnju09b9iBPjg7K+5ENIw==": [2, 78, 4, 10],
- "Ja6RJq5LQftdl7NQrX1avQ==": [2, 56, 4, 24],
- "Jy26Qt99JrUderAcURtQ5A==": [2, 89],
- "sZnJyyzY9QcN810Q6jfbvw==": [2, 43],
- "QhmteGKeYk0okuB/bXzwRw==": [2, 65],
- "CKQZZ1IJjzjjE4LUV8vUSg==": [2, 67],
- "FK7mL5E1JaE6VzOiGMmlZg==": [2, 89],
- "mzcR/nhDcrs0ed4kTf+ZFg==": [2, 99],
-};
-
-const TEST_DOMAIN_TO_CATEGORIES_MAP_INCONCLUSIVE = {
- "IkOfhoSlHTMIZzWXkYf7fg==": [0, 0],
- "PIAHxeaBOeDNY2tvZKqQuw==": [0, 0],
- "DKx2mqmFtEvxrHAqpwSevA==": [0, 0],
- "DlZKnz9ryYqbxJq9wodzlA==": [0, 0],
- "n3NWT4N9JlKX0I7MUtAsYg==": [0, 0],
- "A6KyupOlu5zXt8loti90qw==": [0, 0],
- "gf5rpseruOaq8nXOSJPG3Q==": [0, 0],
- "vlQYOvbcbAp6sMx54OwqCQ==": [0, 0],
- "8PcaPATLgmHD9SR0/961Sw==": [0, 0],
- "l+hLycEAW2v/OPE/XFpNwQ==": [0, 0],
-};
-
-const TEST_DOMAIN_TO_CATEGORIES_MAP_UNKNOWN_AND_INCONCLUSIVE = {
- "CEA642T3hV+Fdi2PaRH9BQ==": [0, 0],
- "cVqopYLASYxcWdDW4F+w2w==": [0, 0],
- "X61OdTU20n8pxZ76K2eAHg==": [0, 0],
- "/srrOggOAwgaBGCsPdC4bA==": [0, 0],
- "onnMGn+MmaCQx3RNLBzGOQ==": [0, 0],
-};
-
-const TEST_DOMAIN_TO_CATEGORIES_MAP_ALL_TYPES = {
- "VSXaqgDKYWrJ/yjsFomUdg==": [3, 90],
- "6re74Kk34n2V6VCdLmCD5w==": [3, 88],
- "s8gOGIaFnly5hHX7nPncnw==": [3, 90, 6, 2],
- "zfRJyKV+2jd1RKNsSHm9pw==": [3, 78, 6, 7],
- "zcW+KbRfLRO6Dljf5qnuwQ==": [3, 97],
- "Rau9mfbBcIRiRQIliUxkow==": [0, 0],
- "4AFhUOmLQ8804doOsI4jBA==": [0, 0],
-};
-
-const TEST_DOMAIN_TO_CATEGORIES_MAP_TIE = {
- "fmEqRSc+pBr9noi0l99nGw==": [1, 50, 2, 50],
- "cms8ipz0JQ3WS9o48RtvnQ==": [1, 50, 2, 50],
- "y8Haj7Qdmx+k762RaxCPvA==": [1, 50, 2, 50],
- "tCbLmi5xJ/OrF8tbRm8PrA==": [1, 50, 2, 50],
- "uYNQECmDShqI409HrSTdLQ==": [1, 50, 2, 50],
- "D88hdsmzLWIXYhkrDal33w==": [3, 50, 4, 50],
- "1mhx0I0B4cEaI91x8zor7Q==": [5, 50, 6, 50],
- "dVZYATQixuBHmalCFR9+Lw==": [7, 50, 8, 50],
- "pdOFJG49D7hE/+FtsWDihQ==": [9, 50, 10, 50],
- "+gl+dBhWE0nx0AM69m2g5w==": [11, 50, 12, 50],
-};
-
-const TEST_DOMAIN_TO_CATEGORIES_MAP_RANK_PENALIZATION_1 = {
- "VSXaqgDKYWrJ/yjsFomUdg==": [1, 45],
- "6re74Kk34n2V6VCdLmCD5w==": [2, 45],
- "s8gOGIaFnly5hHX7nPncnw==": [3, 45],
- "zfRJyKV+2jd1RKNsSHm9pw==": [4, 45],
- "zcW+KbRfLRO6Dljf5qnuwQ==": [5, 45],
- "Rau9mfbBcIRiRQIliUxkow==": [6, 45],
- "4AFhUOmLQ8804doOsI4jBA==": [7, 45],
- "YZ3aEL73MR+Cjog0D7A24w==": [8, 45],
- "crMclD9rwInEQ30DpZLg+g==": [9, 45],
- "/r7oPRoE6LJAE95nuwmu7w==": [10, 45],
-};
-
-const TEST_DOMAIN_TO_CATEGORIES_MAP_RANK_PENALIZATION_2 = {
- "sHWSmFwSYL3snycBZCY8Kg==": [1, 35, 2, 4],
- "FZ5zPYh6ByI0KGWKkmpDoA==": [1, 5, 2, 94],
-};
+ChromeUtils.defineLazyGetter(this, "gCryptoHash", () => {
+ return Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
+});
+
+function convertDomainsToHashes(domainsToCategories) {
+ let newObj = {};
+ for (let [key, value] of Object.entries(domainsToCategories)) {
+ gCryptoHash.init(gCryptoHash.SHA256);
+ let bytes = new TextEncoder().encode(key);
+ gCryptoHash.update(bytes, key.length);
+ let hash = gCryptoHash.finish(true);
+ newObj[hash] = value;
+ }
+ return newObj;
+}
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_SIMPLE = convertDomainsToHashes({
+ "test1.com": [2, 90],
+ "test2.com": [2, 95],
+ "test3.com": [2, 78, 4, 10],
+ "test4.com": [2, 56, 4, 24],
+ "test5.com": [2, 89],
+ "test6.com": [2, 43],
+ "test7.com": [2, 65],
+ "test8.com": [2, 67],
+ "test9.com": [2, 89],
+ "test10.com": [2, 99],
+});
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_INCONCLUSIVE = convertDomainsToHashes({
+ "test11.com": [0, 0],
+ "test12.com": [0, 0],
+ "test13.com": [0, 0],
+ "test14.com": [0, 0],
+ "test15.com": [0, 0],
+ "test16.com": [0, 0],
+ "test17.com": [0, 0],
+ "test18.com": [0, 0],
+ "test19.com": [0, 0],
+ "test20.com": [0, 0],
+});
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_UNKNOWN_AND_INCONCLUSIVE =
+ convertDomainsToHashes({
+ "test31.com": [0, 0],
+ "test32.com": [0, 0],
+ "test33.com": [0, 0],
+ "test34.com": [0, 0],
+ "test35.com": [0, 0],
+ });
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_ALL_TYPES = convertDomainsToHashes({
+ "test51.com": [3, 90],
+ "test52.com": [3, 88],
+ "test53.com": [3, 90, 6, 2],
+ "test54.com": [3, 78, 6, 7],
+ "test55.com": [3, 97],
+ "test56.com": [0, 0],
+ "test57.com": [0, 0],
+});
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_TIE = convertDomainsToHashes({
+ "test41.com": [1, 50, 2, 50],
+ "test42.com": [1, 50, 2, 50],
+ "test43.com": [1, 50, 2, 50],
+ "test44.com": [1, 50, 2, 50],
+ "test45.com": [1, 50, 2, 50],
+ "test46.com": [3, 50, 4, 50],
+ "test47.com": [5, 50, 6, 50],
+ "test48.com": [7, 50, 8, 50],
+ "test49.com": [9, 50, 10, 50],
+ "test50.com": [11, 50, 12, 50],
+});
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_RANK_PENALIZATION_1 =
+ convertDomainsToHashes({
+ "test51.com": [1, 45],
+ "test52.com": [2, 45],
+ "test53.com": [3, 45],
+ "test54.com": [4, 45],
+ "test55.com": [5, 45],
+ "test56.com": [6, 45],
+ "test57.com": [7, 45],
+ "test58.com": [8, 45],
+ "test59.com": [9, 45],
+ "test60.com": [10, 45],
+ });
+
+const TEST_DOMAIN_TO_CATEGORIES_MAP_RANK_PENALIZATION_2 =
+ convertDomainsToHashes({
+ "test61.com": [1, 35, 2, 4],
+ "test62.com": [1, 5, 2, 94],
+ });
add_setup(async () => {
+ do_get_profile();
Services.prefs.setBoolPref(
"browser.search.serpEventTelemetryCategorization.enabled",
true
);
+ await SearchSERPDomainToCategoriesMap.init();
});
add_task(async function test_categorization_simple() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_SIMPLE
);
@@ -115,8 +136,9 @@ add_task(async function test_categorization_simple() {
"test10.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
@@ -126,7 +148,7 @@ add_task(async function test_categorization_simple() {
});
add_task(async function test_categorization_inconclusive() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_INCONCLUSIVE
);
@@ -143,8 +165,9 @@ add_task(async function test_categorization_inconclusive() {
"test20.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
@@ -161,7 +184,7 @@ add_task(async function test_categorization_inconclusive() {
add_task(async function test_categorization_unknown() {
// Reusing TEST_DOMAIN_TO_CATEGORIES_MAP_SIMPLE since none of this task's
// domains will be keys within it.
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_SIMPLE
);
@@ -178,8 +201,9 @@ add_task(async function test_categorization_unknown() {
"test30.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
@@ -194,7 +218,7 @@ add_task(async function test_categorization_unknown() {
});
add_task(async function test_categorization_unknown_and_inconclusive() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_UNKNOWN_AND_INCONCLUSIVE
);
@@ -211,8 +235,9 @@ add_task(async function test_categorization_unknown_and_inconclusive() {
"test40.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
@@ -228,7 +253,7 @@ add_task(async function test_categorization_unknown_and_inconclusive() {
// Tests a mixture of categorized, inconclusive and unknown domains.
add_task(async function test_categorization_all_types() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_ALL_TYPES
);
@@ -247,8 +272,9 @@ add_task(async function test_categorization_all_types() {
"test60.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
@@ -263,7 +289,7 @@ add_task(async function test_categorization_all_types() {
});
add_task(async function test_categorization_tie() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_TIE
);
@@ -280,8 +306,9 @@ add_task(async function test_categorization_tie() {
"test50.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.equal(
[1, 2].includes(resultsToReport.category),
@@ -301,7 +328,7 @@ add_task(async function test_categorization_tie() {
});
add_task(async function test_rank_penalization_equal_scores() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_RANK_PENALIZATION_1
);
@@ -318,8 +345,9 @@ add_task(async function test_rank_penalization_equal_scores() {
"test60.com",
]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
@@ -329,14 +357,15 @@ add_task(async function test_rank_penalization_equal_scores() {
});
add_task(async function test_rank_penalization_highest_score_lower_on_page() {
- SearchSERPDomainToCategoriesMap.overrideMapForTests(
+ await SearchSERPDomainToCategoriesMap.overrideMapForTests(
TEST_DOMAIN_TO_CATEGORIES_MAP_RANK_PENALIZATION_2
);
let domains = new Set(["test61.com", "test62.com"]);
- let resultsToReport =
- SearchSERPCategorization.applyCategorizationLogic(domains);
+ let resultsToReport = await SearchSERPCategorization.applyCategorizationLogic(
+ domains
+ );
Assert.deepEqual(
resultsToReport,
diff --git a/browser/components/search/test/unit/test_search_telemetry_categorization_process_domains.js b/browser/components/search/test/unit/test_search_telemetry_categorization_process_domains.js
deleted file mode 100644
index 84acedaa7a..0000000000
--- a/browser/components/search/test/unit/test_search_telemetry_categorization_process_domains.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * This test ensures we are correctly processing the domains that have been
- * extracted from a SERP.
- */
-
-ChromeUtils.defineESModuleGetters(this, {
- BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
- SearchSERPCategorization: "resource:///modules/SearchSERPTelemetry.sys.mjs",
- SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
- SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
- sinon: "resource://testing-common/Sinon.sys.mjs",
-});
-
-// Links including the provider name are not extracted.
-const PROVIDER = "example";
-
-const TESTS = [
- {
- title: "Domains matching the provider.",
- domains: ["example.com", "www.example.com", "www.foobar.com"],
- expected: ["foobar.com"],
- },
- {
- title: "Second-level domains to a top-level domain.",
- domains: [
- "www.foobar.gc.ca",
- "www.foobar.gov.uk",
- "foobar.co.uk",
- "www.foobar.co.il",
- ],
- expected: ["foobar.gc.ca", "foobar.gov.uk", "foobar.co.uk", "foobar.co.il"],
- },
- {
- title: "Long subdomain.",
- domains: ["ab.cd.ef.gh.foobar.com"],
- expected: ["foobar.com"],
- },
- {
- title: "Same top-level domain.",
- domains: ["foobar.com", "www.foobar.com", "abc.def.foobar.com"],
- expected: ["foobar.com"],
- },
- {
- title: "Empty input.",
- domains: [""],
- expected: [],
- },
-];
-
-add_setup(async function () {
- Services.prefs.setBoolPref(
- SearchUtils.BROWSER_SEARCH_PREF + "serpEventTelemetry.enabled",
- true
- );
- Services.prefs.setBoolPref(
- SearchUtils.BROWSER_SEARCH_PREF +
- "serpEventTelemetryCategorization.enabled",
- true
- );
-
- // Required or else BrowserSearchTelemetry will throw.
- sinon.stub(BrowserSearchTelemetry, "shouldRecordSearchCount").returns(true);
- await SearchSERPTelemetry.init();
-});
-
-add_task(async function test_parsing_extracted_urls() {
- for (let i = 0; i < TESTS.length; i++) {
- let currentTest = TESTS[i];
- let domains = new Set(currentTest.domains);
-
- if (currentTest.title) {
- info(currentTest.title);
- }
- let expectedDomains = new Set(currentTest.expected);
- let actualDomains = SearchSERPCategorization.processDomains(
- domains,
- PROVIDER
- );
-
- Assert.deepEqual(
- Array.from(actualDomains),
- Array.from(expectedDomains),
- "Domains should have been parsed correctly."
- );
- }
-});
diff --git a/browser/components/search/test/unit/test_search_telemetry_categorization_sync.js b/browser/components/search/test/unit/test_search_telemetry_categorization_sync.js
index 423ee0a81d..40d38efbba 100644
--- a/browser/components/search/test/unit/test_search_telemetry_categorization_sync.js
+++ b/browser/components/search/test/unit/test_search_telemetry_categorization_sync.js
@@ -16,16 +16,34 @@ ChromeUtils.defineESModuleGetters(this, {
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
});
+ChromeUtils.defineLazyGetter(this, "gCryptoHash", () => {
+ return Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
+});
+
+function convertDomainsToHashes(domainsToCategories) {
+ let newObj = {};
+ for (let [key, value] of Object.entries(domainsToCategories)) {
+ gCryptoHash.init(gCryptoHash.SHA256);
+ let bytes = new TextEncoder().encode(key);
+ gCryptoHash.update(bytes, key.length);
+ let hash = gCryptoHash.finish(true);
+ newObj[hash] = value;
+ }
+ return newObj;
+}
+
async function waitForDomainToCategoriesUpdate() {
return TestUtils.topicObserved("domain-to-categories-map-update-complete");
}
-async function mockRecordWithCachedAttachment({ id, version, filename }) {
+async function mockRecordWithCachedAttachment({
+ id,
+ version,
+ filename,
+ mapping,
+}) {
// Get the bytes of the file for the hash and size for attachment metadata.
- let data = await IOUtils.readUTF8(
- PathUtils.join(do_get_cwd().path, filename)
- );
- let buffer = new TextEncoder().encode(data).buffer;
+ let buffer = new TextEncoder().encode(JSON.stringify(mapping)).buffer;
let stream = Cc["@mozilla.org/io/arraybuffer-input-stream;1"].createInstance(
Ci.nsIArrayBufferInputStream
);
@@ -73,21 +91,33 @@ const RECORDS = {
id: RECORD_A_ID,
version: 1,
filename: "domain_category_mappings_1a.json",
+ mapping: convertDomainsToHashes({
+ "example.com": [1, 100],
+ }),
},
record1b: {
id: RECORD_B_ID,
version: 1,
filename: "domain_category_mappings_1b.json",
+ mapping: convertDomainsToHashes({
+ "example.org": [2, 90],
+ }),
},
record2a: {
id: RECORD_A_ID,
version: 2,
filename: "domain_category_mappings_2a.json",
+ mapping: convertDomainsToHashes({
+ "example.com": [1, 80],
+ }),
},
record2b: {
id: RECORD_B_ID,
version: 2,
filename: "domain_category_mappings_2b.json",
+ mapping: convertDomainsToHashes({
+ "example.org": [2, 50, 4, 80],
+ }),
},
};
@@ -115,13 +145,13 @@ add_task(async function test_initial_import() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[{ category: 1, score: 100 }],
"Return value from lookup of example.com should be the same."
);
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.org"),
+ await SearchSERPDomainToCategoriesMap.get("example.org"),
[{ category: 2, score: 90 }],
"Return value from lookup of example.org should be the same."
);
@@ -167,13 +197,13 @@ add_task(async function test_update_records() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[{ category: 1, score: 80 }],
"Return value from lookup of example.com should have changed."
);
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.org"),
+ await SearchSERPDomainToCategoriesMap.get("example.org"),
[
{ category: 2, score: 50 },
{ category: 4, score: 80 },
@@ -224,13 +254,13 @@ add_task(async function test_delayed_initial_import() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[{ category: 1, score: 100 }],
"Return value from lookup of example.com should be the same."
);
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.org"),
+ await SearchSERPDomainToCategoriesMap.get("example.org"),
[{ category: 2, score: 90 }],
"Return value from lookup of example.org should be the same."
);
@@ -264,7 +294,7 @@ add_task(async function test_remove_record() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[{ category: 1, score: 80 }],
"Initialized properly."
);
@@ -283,13 +313,13 @@ add_task(async function test_remove_record() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[{ category: 1, score: 80 }],
"Return value from lookup of example.com should remain unchanged."
);
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.org"),
+ await SearchSERPDomainToCategoriesMap.get("example.org"),
[],
"Return value from lookup of example.org should be empty."
);
@@ -323,7 +353,7 @@ add_task(async function test_different_versions_coexisting() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[
{
category: 1,
@@ -334,7 +364,7 @@ add_task(async function test_different_versions_coexisting() {
);
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.org"),
+ await SearchSERPDomainToCategoriesMap.get("example.org"),
[
{ category: 2, score: 50 },
{ category: 4, score: 80 },
@@ -367,7 +397,7 @@ add_task(async function test_download_error() {
await promise;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[
{
category: 1,
@@ -406,7 +436,7 @@ add_task(async function test_download_error() {
await observeDownloadError;
Assert.deepEqual(
- SearchSERPDomainToCategoriesMap.get("example.com"),
+ await SearchSERPDomainToCategoriesMap.get("example.com"),
[],
"Domain should not exist in store."
);
diff --git a/browser/components/search/test/unit/xpcshell.toml b/browser/components/search/test/unit/xpcshell.toml
index 61cdb83378..423d218d19 100644
--- a/browser/components/search/test/unit/xpcshell.toml
+++ b/browser/components/search/test/unit/xpcshell.toml
@@ -8,16 +8,8 @@ firefox-appdir = "browser"
["test_search_telemetry_categorization_logic.js"]
-["test_search_telemetry_categorization_process_domains.js"]
-
["test_search_telemetry_categorization_sync.js"]
prefs = ["browser.search.serpEventTelemetryCategorization.enabled=true"]
-support-files = [
- "domain_category_mappings_1a.json",
- "domain_category_mappings_1b.json",
- "domain_category_mappings_2a.json",
- "domain_category_mappings_2b.json",
-]
["test_search_telemetry_compare_urls.js"]