From 217dd347c1f80bd95441bead922897e7dd9798ef Mon Sep 17 00:00:00 2001 From: Barret Rennie Date: Tue, 3 May 2022 16:37:19 +0000 Subject: [PATCH] Bug 1767266 - Make ExtensionDoorhanger.schema.json more lenient r=Mardak Differential Revision: https://phabricator.services.mozilla.com/D145241 --- .../templates/ExtensionDoorhanger.schema.json | 3 +- .../test/xpcshell/test_PanelTestProvider.js | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/browser/components/newtab/content-src/asrouter/templates/CFR/templates/ExtensionDoorhanger.schema.json b/browser/components/newtab/content-src/asrouter/templates/CFR/templates/ExtensionDoorhanger.schema.json index 5f08da04f5b9..84e2803b6fb7 100644 --- a/browser/components/newtab/content-src/asrouter/templates/CFR/templates/ExtensionDoorhanger.schema.json +++ b/browser/components/newtab/content-src/asrouter/templates/CFR/templates/ExtensionDoorhanger.schema.json @@ -387,7 +387,7 @@ } } }, - "additionalProperties": false, + "additionalProperties": true, "required": [ "layout", "category", @@ -427,5 +427,6 @@ "required": ["id"] } }, + "additionalProperties": true, "required": ["id", "groups", "content", "targeting", "template", "trigger"] } diff --git a/browser/components/newtab/test/xpcshell/test_PanelTestProvider.js b/browser/components/newtab/test/xpcshell/test_PanelTestProvider.js index 05bb896d1438..d6f1ccc734fe 100644 --- a/browser/components/newtab/test/xpcshell/test_PanelTestProvider.js +++ b/browser/components/newtab/test/xpcshell/test_PanelTestProvider.js @@ -10,6 +10,7 @@ const { JsonSchema } = ChromeUtils.import( Cu.importGlobalProperties(["fetch"]); +let CFR_SCHEMA; let UPDATE_ACTION_SCHEMA; let WHATS_NEW_SCHEMA; let SPOTLIGHT_SCHEMA; @@ -20,6 +21,9 @@ add_setup(async function setup() { return fetch(uri, { credentials: "omit" }).then(rsp => rsp.json()); } + CFR_SCHEMA = await fetchSchema( + "resource://activity-stream/schemas/CFR/ExtensionDoorhanger.schema.json" + ); UPDATE_ACTION_SCHEMA = await fetchSchema( "resource://activity-stream/schemas/OnboardingMessage/UpdateAction.schema.json" ); @@ -103,3 +107,35 @@ add_task(async function test_PanelTestProvider() { "There is one pb_newtab message" ); }); + +add_task(async function test_SpotlightAsCFR() { + let message = await PanelTestProvider.getMessages().then(msgs => + msgs.find(msg => msg.id === "TCP_SPOTLIGHT_MESSAGE_95") + ); + + message = { + ...message, + content: { + ...message.content, + category: "", + layout: "icon_and_message", + bucket_id: "", + notification_text: "", + heading_text: "", + text: "", + buttons: {}, + }, + }; + + assertSchema( + message, + CFR_SCHEMA, + "Munged spotlight message validates with CFR ExtensionDoorhanger schema" + ); + + assertSchema( + message, + SPOTLIGHT_SCHEMA, + "Munged Spotlight message validates with Spotlight schema" + ); +});