diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js')
-rw-r--r-- | toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js b/toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js index 4ba120852f..ff87da1dde 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_dnr_dynamic_rules.js @@ -414,10 +414,10 @@ add_task(async function test_save_and_load_dynamic_rules() { browser.test.onMessage.addListener(async (msg, ...args) => { switch (msg) { case "assertGetDynamicRules": { - const [{ expectedRules }] = args; + const [{ expectedRules, filter }] = args; browser.test.assertDeepEq( expectedRules, - await dnr.getDynamicRules(), + await dnr.getDynamicRules(filter), "getDynamicRules() resolves to the expected dynamic rules" ); break; @@ -503,6 +503,35 @@ add_task(async function test_save_and_load_dynamic_rules() { expectedRules: getSchemaNormalizedRules(extension, rules), }); + info("Verify getDynamicRules with some filters"); + // An empty list of rule IDs should return no rule. + await callTestMessageHandler(extension, "assertGetDynamicRules", { + expectedRules: [], + filter: { ruleIds: [] }, + }); + // Non-existent rule ID. + await callTestMessageHandler(extension, "assertGetDynamicRules", { + expectedRules: [], + filter: { ruleIds: [456] }, + }); + await callTestMessageHandler(extension, "assertGetDynamicRules", { + expectedRules: getSchemaNormalizedRules(extension, [rules[0]]), + filter: { ruleIds: [rules[0].id] }, + }); + await callTestMessageHandler(extension, "assertGetDynamicRules", { + expectedRules: getSchemaNormalizedRules(extension, [rules[1]]), + filter: { ruleIds: [rules[1].id] }, + }); + await callTestMessageHandler(extension, "assertGetDynamicRules", { + expectedRules: getSchemaNormalizedRules(extension, rules), + filter: { ruleIds: rules.map(rule => rule.id) }, + }); + // When `ruleIds` isn't defined, we return all the rules. + await callTestMessageHandler(extension, "assertGetDynamicRules", { + expectedRules: getSchemaNormalizedRules(extension, rules), + filter: {}, + }); + const extUUID = extension.uuid; const dnrStore = ExtensionDNRStore._getStoreForTesting(); await dnrStore._savePromises.get(extUUID); |