Bug 1878281 - Stub out NEWTAB_MESSAGE_REQUEST handling for legacy privileged addons. r=mkaply,omc-reviewers,pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D201094
This commit is contained in:
Mike Conley
2024-02-09 21:29:46 +00:00
parent b4e1373144
commit cbeae19a3b
3 changed files with 28 additions and 0 deletions

View File

@@ -91,6 +91,13 @@ export class ASRouterChild extends JSWindowActorChild {
}
asRouterMessage({ type, data }) {
// Some legacy privileged addons send this message, but it got removed from
// VALID_TYPES in bug 1715158. Thankfully, these addons don't appear to
// require any actions from this message - just a Promise that resolves.
if (type === "NEWTAB_MESSAGE_REQUEST") {
return this.wrapPromise(Promise.resolve());
}
if (VALID_TYPES.has(type)) {
switch (type) {
case msg.DISABLE_PROVIDER:

View File

@@ -55,5 +55,17 @@ describe("ASRouterChild", () => {
});
});
});
// Some legacy privileged extensions still send this legacy NEWTAB_MESSAGE_REQUEST
// action type. We simply
it("can accept the legacy NEWTAB_MESSAGE_REQUEST message without throwing", async () => {
assert.doesNotThrow(async () => {
let result = await asRouterChild.asRouterMessage({
type: "NEWTAB_MESSAGE_REQUEST",
data: {},
});
sandbox.assert.deepEqual(result, {});
sandbox.assert.notCalled(asRouterChild.sendAsyncMessage);
});
});
});
});

View File

@@ -27,6 +27,15 @@ describe("ASRouterUtils", () => {
overrider.set("ASRouterMessage", undefined);
assert.throws(() => ASRouterUtils.sendMessage({ foo: "bar" }));
});
it("can accept the legacy NEWTAB_MESSAGE_REQUEST message without throwing", async () => {
assert.doesNotThrow(async () => {
let result = await ASRouterUtils.sendMessage({
type: "NEWTAB_MESSAGE_REQUEST",
data: {},
});
sandbox.assert.deepEqual(result, {});
});
});
});
describe("blockById", () => {
it("default", () => {