From 051dfe31ad92be221ef024fe837baa9052cd9b22 Mon Sep 17 00:00:00 2001 From: Barret Rennie Date: Fri, 25 Mar 2022 00:01:19 +0000 Subject: [PATCH] Bug 1757778 - Expose Nimbus schemas as resource:// URIs r=andreio Differential Revision: https://phabricator.services.mozilla.com/D138929 --- .../test/static/browser_all_files_referenced.js | 3 +++ toolkit/components/nimbus/jar.mn | 2 ++ toolkit/components/nimbus/moz.build | 4 ---- toolkit/components/nimbus/test/NimbusTestUtils.jsm | 6 +++--- .../test/unit/test_ExperimentAPI_NimbusFeatures.js | 13 ++++--------- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/browser/base/content/test/static/browser_all_files_referenced.js b/browser/base/content/test/static/browser_all_files_referenced.js index 8abbcb2cd1c3..4644c3021e26 100644 --- a/browser/base/content/test/static/browser_all_files_referenced.js +++ b/browser/base/content/test/static/browser_all_files_referenced.js @@ -65,6 +65,9 @@ var gExceptionPaths = [ // Page data schemas are referenced programmatically. "chrome://browser/content/pagedata/schemas/", + + // Nimbus schemas are referenced programmatically. + "resource://nimbus/schemas/", ]; // These are not part of the omni.ja file, so we find them only when running diff --git a/toolkit/components/nimbus/jar.mn b/toolkit/components/nimbus/jar.mn index a7dd79ad89ba..19e2ede5c9ba 100644 --- a/toolkit/components/nimbus/jar.mn +++ b/toolkit/components/nimbus/jar.mn @@ -7,3 +7,5 @@ toolkit.jar: res/nimbus/lib/ (./lib/*.jsm) res/nimbus/ExperimentAPI.jsm (./ExperimentAPI.jsm) res/nimbus/FeatureManifest.js (FeatureManifest.js) + res/nimbus/schemas/NimbusEnrollment.schema.json (./schemas/NimbusEnrollment.schema.json) + res/nimbus/schemas/NimbusExperiment.schema.json (./schemas/NimbusExperiment.schema.json) diff --git a/toolkit/components/nimbus/moz.build b/toolkit/components/nimbus/moz.build index 0eee7a00bbf9..8f1ada80cf9e 100644 --- a/toolkit/components/nimbus/moz.build +++ b/toolkit/components/nimbus/moz.build @@ -29,10 +29,6 @@ XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"] SPHINX_TREES["docs"] = "docs" TESTING_JS_MODULES += [ - "schemas/ExperimentFeatureManifest.schema.json", - "schemas/ExperimentFeatureRemote.schema.json", - "schemas/NimbusEnrollment.schema.json", - "schemas/NimbusExperiment.schema.json", "test/NimbusTestUtils.jsm", ] diff --git a/toolkit/components/nimbus/test/NimbusTestUtils.jsm b/toolkit/components/nimbus/test/NimbusTestUtils.jsm index f0c25aa96095..e756347afaf8 100644 --- a/toolkit/components/nimbus/test/NimbusTestUtils.jsm +++ b/toolkit/components/nimbus/test/NimbusTestUtils.jsm @@ -84,7 +84,7 @@ const ExperimentTestUtils = { async validateExperiment(experiment) { const schema = ( await fetchSchema( - "resource://testing-common/NimbusExperiment.schema.json" + "resource://nimbus/schemas/NimbusExperiment.schema.json" ) ).NimbusExperiment; @@ -109,7 +109,7 @@ const ExperimentTestUtils = { async validateEnrollment(enrollment) { const schema = ( await fetchSchema( - "resource://testing-common/NimbusEnrollment.schema.json" + "resource://nimbus/schemas/NimbusEnrollment.schema.json" ) ).NimbusExperiment; @@ -131,7 +131,7 @@ const ExperimentTestUtils = { async validateRollouts(rollout) { const schema = ( await fetchSchema( - "resource://testing-common/NimbusEnrollment.schema.json" + "resource://nimbus/schemas/NimbusEnrollment.schema.json" ) ).NimbusExperiment; diff --git a/toolkit/components/nimbus/test/unit/test_ExperimentAPI_NimbusFeatures.js b/toolkit/components/nimbus/test/unit/test_ExperimentAPI_NimbusFeatures.js index d360148556ac..8bb21a9966a8 100644 --- a/toolkit/components/nimbus/test/unit/test_ExperimentAPI_NimbusFeatures.js +++ b/toolkit/components/nimbus/test/unit/test_ExperimentAPI_NimbusFeatures.js @@ -7,15 +7,10 @@ const { Cu.importGlobalProperties(["fetch"]); -XPCOMUtils.defineLazyGetter(this, "fetchSchema", async () => { - const response = await fetch( - "resource://testing-common/NimbusEnrollment.schema.json" - ); - const schema = await response.json(); - if (!schema) { - throw new Error("Failed to load ExperimentFeatureRemote schema"); - } - return schema.definitions.NimbusExperiment; +XPCOMUtils.defineLazyGetter(this, "fetchSchema", () => { + return fetch("resource://nimbus/schemas/NimbusEnrollment.schema.json", { + credentials: "omit", + }).then(rsp => rsp.json()); }); const NON_MATCHING_ROLLOUT = Object.freeze(