icecat: add release icecat-140.8.0-2 for aramo
This commit is contained in:
parent
d9a6c0aa96
commit
d570f39e11
616 changed files with 39955 additions and 33937 deletions
|
|
@ -968,14 +968,27 @@ add_task(async function test_register_dynamic_rules_after_restart() {
|
|||
// been detected at the previous session. Caching too much or too little in
|
||||
// StartupCache will trigger test failures in assertStoreReadsSinceLastCall.
|
||||
const sandboxStoreSpies = sinon.createSandbox();
|
||||
const dnrStore = ExtensionDNRStore._getStoreForTesting();
|
||||
const spyReadDNRStore = sandboxStoreSpies.spy(dnrStore, "_readData");
|
||||
let dnrStore = ExtensionDNRStore._getStoreForTesting();
|
||||
const spyReadDNRStore = sandboxStoreSpies.spy(
|
||||
Object.getPrototypeOf(dnrStore),
|
||||
"_readData"
|
||||
);
|
||||
|
||||
function assertStoreReadsSinceLastCall(expectedCount, description) {
|
||||
equal(spyReadDNRStore.callCount, expectedCount, description);
|
||||
spyReadDNRStore.resetHistory();
|
||||
}
|
||||
|
||||
async function promiseRestartManagerWithRealisticDNRStoreInMemory() {
|
||||
await AddonTestUtils.promiseShutdownManager();
|
||||
// Recreate the DNR store to ensure that we test a realistic state without
|
||||
// cached in-memory state.
|
||||
dnrStore = ExtensionDNRStore._recreateStoreForTesting();
|
||||
// After the store is recreated for testing, we will still be able to track
|
||||
// reads, because spyReadDNRStore was attached to the prototype above.
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
}
|
||||
|
||||
let { extension } = await runAsDNRExtension({
|
||||
unloadTestAtEnd: false,
|
||||
id: "test-dnr-restart-and-rule-registration-changes@test-extension",
|
||||
|
|
@ -1015,7 +1028,7 @@ add_task(async function test_register_dynamic_rules_after_restart() {
|
|||
});
|
||||
await extension.awaitMessage("onInstalled");
|
||||
assertStoreReadsSinceLastCall(1, "Read once at initial startup");
|
||||
await promiseRestartManager();
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
await extension.awaitMessage("onStartup");
|
||||
assertStoreReadsSinceLastCall(0, "Read skipped due to hasDynamicRules=false");
|
||||
|
||||
|
|
@ -1031,7 +1044,7 @@ add_task(async function test_register_dynamic_rules_after_restart() {
|
|||
await callTestMessageHandler(extension, "zero_to_one_rule");
|
||||
|
||||
assertStoreReadsSinceLastCall(0, "No further reads before restart");
|
||||
await promiseRestartManager();
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
await extension.awaitMessage("onStartup");
|
||||
|
||||
// Regression test 2: before bug 1921353 was fixed, even with a fix to the
|
||||
|
|
@ -1048,7 +1061,7 @@ add_task(async function test_register_dynamic_rules_after_restart() {
|
|||
// the initialization is skipped as expected.
|
||||
|
||||
await callTestMessageHandler(extension, "one_to_zero_rules");
|
||||
await promiseRestartManager();
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
await extension.awaitMessage("onStartup");
|
||||
assertStoreReadsSinceLastCall(0, "Read skipped because rules were cleared");
|
||||
equal(
|
||||
|
|
@ -1060,7 +1073,47 @@ add_task(async function test_register_dynamic_rules_after_restart() {
|
|||
// not expect another read from disk.
|
||||
assertStoreReadsSinceLastCall(0, "Read still skipped despite API call");
|
||||
|
||||
// Regression test for bug 2006233: The skipped read (for extension without
|
||||
// enabled rules) should not prevent the read for extension2 (with rules).
|
||||
const { extension: extension2 } = await runAsDNRExtension({
|
||||
unloadTestAtEnd: false,
|
||||
id: "test-dnr-restart-with-rules-after-one-without@test-extension",
|
||||
background: () => {
|
||||
const dnr = browser.declarativeNetRequest;
|
||||
|
||||
browser.runtime.onInstalled.addListener(async () => {
|
||||
await dnr.updateDynamicRules({
|
||||
addRules: [{ id: 1, condition: {}, action: { type: "block" } }],
|
||||
});
|
||||
browser.test.sendMessage("dynamic_rules_registered_on_install");
|
||||
});
|
||||
browser.runtime.onStartup.addListener(async () => {
|
||||
browser.test.assertEq(
|
||||
1,
|
||||
(await dnr.getDynamicRules()).length,
|
||||
"Rule still registered after restart"
|
||||
);
|
||||
browser.test.sendMessage("dynamic_rules_still_registered");
|
||||
});
|
||||
},
|
||||
});
|
||||
await extension2.awaitMessage("dynamic_rules_registered_on_install");
|
||||
assertStoreReadsSinceLastCall(1, "Read for new extension");
|
||||
|
||||
await dnrStore.waitSaveCacheDataForTesting();
|
||||
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
await extension.awaitMessage("onStartup");
|
||||
await extension2.awaitMessage("dynamic_rules_still_registered");
|
||||
assertStoreReadsSinceLastCall(1, "Read due to extension2 with dynamic rules");
|
||||
|
||||
ok(
|
||||
dnrStore._data.get(extension2.uuid).isFromStartupCache(),
|
||||
"extension2 StoreData should be initialized from startup cache"
|
||||
);
|
||||
|
||||
await extension.unload();
|
||||
await extension2.unload();
|
||||
|
||||
sandboxStoreSpies.restore();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -333,14 +333,27 @@ add_task(async function test_enable_disabled_static_rules_after_restart() {
|
|||
// been detected at the previous session. Caching too much or too little in
|
||||
// StartupCache will trigger test failures in assertStoreReadsSinceLastCall.
|
||||
const sandboxStoreSpies = sinon.createSandbox();
|
||||
const dnrStore = ExtensionDNRStore._getStoreForTesting();
|
||||
const spyReadDNRStore = sandboxStoreSpies.spy(dnrStore, "_readData");
|
||||
let dnrStore = ExtensionDNRStore._getStoreForTesting();
|
||||
const spyReadDNRStore = sandboxStoreSpies.spy(
|
||||
Object.getPrototypeOf(dnrStore),
|
||||
"_readData"
|
||||
);
|
||||
|
||||
function assertStoreReadsSinceLastCall(expectedCount, description) {
|
||||
equal(spyReadDNRStore.callCount, expectedCount, description);
|
||||
spyReadDNRStore.resetHistory();
|
||||
}
|
||||
|
||||
async function promiseRestartManagerWithRealisticDNRStoreInMemory() {
|
||||
await AddonTestUtils.promiseShutdownManager();
|
||||
// Recreate the DNR store to ensure that we test a realistic state without
|
||||
// cached in-memory state.
|
||||
dnrStore = ExtensionDNRStore._recreateStoreForTesting();
|
||||
// After the store is recreated for testing, we will still be able to track
|
||||
// reads, because spyReadDNRStore was attached to the prototype above.
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
}
|
||||
|
||||
const rule_resources = [
|
||||
{
|
||||
id: "ruleset_initially_disabled",
|
||||
|
|
@ -360,7 +373,7 @@ add_task(async function test_enable_disabled_static_rules_after_restart() {
|
|||
await extension.awaitMessage("bgpage:ready");
|
||||
|
||||
assertStoreReadsSinceLastCall(1, "Read once at initial startup");
|
||||
await AddonTestUtils.promiseRestartManager();
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
// Note: ordinarily, event pages do not wake up after a browser restart,
|
||||
// unless a relevant event such as runtime.onStartup is triggered. But as
|
||||
// noted in bug 1822735, "event pages without any event listeners" will be
|
||||
|
|
@ -394,7 +407,7 @@ add_task(async function test_enable_disabled_static_rules_after_restart() {
|
|||
await assertDNRGetEnabledRulesets(extension, ["ruleset_initially_disabled"]);
|
||||
|
||||
assertStoreReadsSinceLastCall(0, "No further reads before restart");
|
||||
await AddonTestUtils.promiseRestartManager();
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
await extension.awaitMessage("bgpage:ready");
|
||||
|
||||
// Regression test 2: before bug 1921353 was fixed, even with a fix to the
|
||||
|
|
@ -414,7 +427,7 @@ add_task(async function test_enable_disabled_static_rules_after_restart() {
|
|||
await extension.awaitMessage("updateEnabledRulesets:done");
|
||||
await assertDNRGetEnabledRulesets(extension, []);
|
||||
|
||||
await AddonTestUtils.promiseRestartManager();
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
await extension.awaitMessage("bgpage:ready");
|
||||
assertStoreReadsSinceLastCall(0, "Read skipped because rules were disabled");
|
||||
await assertDNRGetEnabledRulesets(extension, []);
|
||||
|
|
@ -422,7 +435,35 @@ add_task(async function test_enable_disabled_static_rules_after_restart() {
|
|||
// so we do not expect another read from disk.
|
||||
assertStoreReadsSinceLastCall(0, "Read still skipped despite API call");
|
||||
|
||||
// Regression test for bug 2006233: The skipped read (for extension without
|
||||
// enabled rules) should not prevent the read for extension2 (with rules).
|
||||
const extension2 = ExtensionTestUtils.loadExtension(
|
||||
getDNRExtension({
|
||||
rule_resources: [{ id: "my_ruleset", enabled: true, path: "rules.json" }],
|
||||
files: { "rules.json": JSON.stringify([getDNRRule()]) },
|
||||
id: "dnr@initially-enabled",
|
||||
})
|
||||
);
|
||||
await extension2.startup();
|
||||
await extension2.awaitMessage("bgpage:ready");
|
||||
assertStoreReadsSinceLastCall(1, "Read for new extension");
|
||||
|
||||
await dnrStore.waitSaveCacheDataForTesting();
|
||||
|
||||
await promiseRestartManagerWithRealisticDNRStoreInMemory();
|
||||
|
||||
await extension.awaitMessage("bgpage:ready");
|
||||
await extension2.awaitMessage("bgpage:ready");
|
||||
assertStoreReadsSinceLastCall(1, "Read due to extension2 with enabled rules");
|
||||
await assertDNRGetEnabledRulesets(extension2, ["my_ruleset"]);
|
||||
|
||||
ok(
|
||||
dnrStore._data.get(extension2.uuid).isFromStartupCache(),
|
||||
"extension2 StoreData should be initialized from startup cache"
|
||||
);
|
||||
|
||||
await extension.unload();
|
||||
await extension2.unload();
|
||||
|
||||
sandboxStoreSpies.restore();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue