From a28c02848c3e04a984aa3d0e5cf4f232e6bccd03 Mon Sep 17 00:00:00 2001 From: Mathew Hodson Date: Fri, 22 Oct 2021 12:28:09 +0000 Subject: [PATCH] Bug 1733871 - Allow tests to use `computeHash` from ProductAddonChecker.jsm. r=robwu Differential Revision: https://phabricator.services.mozilla.com/D127387 --- .../extensions/test/browser/browser_ext_management.js | 10 ++++++---- .../extensions/internal/ProductAddonChecker.jsm | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/browser/components/extensions/test/browser/browser_ext_management.js b/browser/components/extensions/test/browser/browser_ext_management.js index a84e17d1684a..672adbc79a27 100644 --- a/browser/components/extensions/test/browser/browser_ext_management.js +++ b/browser/components/extensions/test/browser/browser_ext_management.js @@ -4,9 +4,8 @@ const { AddonTestUtils } = ChromeUtils.import( "resource://testing-common/AddonTestUtils.jsm" ); -const { computeHash } = ChromeUtils.import( - "resource://gre/modules/addons/ProductAddonChecker.jsm", - null +const { ProductAddonChecker } = ChromeUtils.import( + "resource://gre/modules/addons/ProductAddonChecker.jsm" ); AddonTestUtils.initMochitest(this); @@ -70,7 +69,10 @@ add_task(async function test_management_install() { }, }); - let themeXPIFileHash = await computeHash("sha256", themeXPIFile.path); + let themeXPIFileHash = await ProductAddonChecker.computeHash( + "sha256", + themeXPIFile.path + ); const otherXPIFile = AddonTestUtils.createTempWebExtensionFile({ manifest: { diff --git a/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm b/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm index 410fbac1d827..ef9717266a30 100644 --- a/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm +++ b/toolkit/mozapps/extensions/internal/ProductAddonChecker.jsm @@ -398,4 +398,7 @@ const ProductAddonChecker = { throw e; } }, + + // For test use only. + computeHash, };