From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/browser_asrouter_bug1800087.js | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 browser/components/newtab/test/browser/browser_asrouter_bug1800087.js (limited to 'browser/components/newtab/test/browser/browser_asrouter_bug1800087.js') diff --git a/browser/components/newtab/test/browser/browser_asrouter_bug1800087.js b/browser/components/newtab/test/browser/browser_asrouter_bug1800087.js new file mode 100644 index 0000000000..dd7138d00d --- /dev/null +++ b/browser/components/newtab/test/browser/browser_asrouter_bug1800087.js @@ -0,0 +1,48 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// TODO (Bug 1800937): Remove this whole test along with the migration code +// after the next watershed release. + +const { ASRouterNewTabHook } = ChromeUtils.importESModule( + "resource://activity-stream/lib/ASRouterNewTabHook.sys.mjs" +); +const { ASRouterDefaultConfig } = ChromeUtils.import( + "resource://activity-stream/lib/ASRouterDefaultConfig.jsm" +); + +add_setup(() => ASRouterNewTabHook.destroy()); + +// Test that the old pref format is migrated correctly to the new format. +// provider.bucket -> provider.collection +add_task(async function test_newtab_asrouter() { + await SpecialPowers.pushPrefEnv({ + set: [ + [ + "browser.newtabpage.activity-stream.asrouter.providers.cfr", + JSON.stringify({ + id: "cfr", + enabled: true, + type: "local", + bucket: "cfr", // The pre-migration property name is bucket. + updateCyleInMs: 3600000, + }), + ], + ], + }); + + await ASRouterNewTabHook.createInstance(ASRouterDefaultConfig()); + const hook = await ASRouterNewTabHook.getInstance(); + const router = hook._router; + if (!router.initialized) { + await router.waitForInitialized; + } + + // Test that the pref's bucket is migrated to collection. + let cfrProvider = router.state.providers.find(p => p.id === "cfr"); + Assert.equal(cfrProvider.collection, "cfr", "The collection name is correct"); + Assert.ok(!cfrProvider.bucket, "The bucket name is removed"); +}); -- cgit v1.2.3