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 --- .../tests/browser/browser_policy_firefoxhome.js | 132 +++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js (limited to 'browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js') diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js new file mode 100644 index 0000000000..67afe70c2f --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js @@ -0,0 +1,132 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_setup(async function () { + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.newtabpage.activity-stream.feeds.section.highlights", true], + ], + }); +}); + +add_task(async function test_firefox_home_without_policy_without_pocket() { + let tab = await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + opening: "about:home", + waitForStateStop: true, + }); + + await SpecialPowers.spawn(tab.linkedBrowser, [], function () { + let search = content.document.querySelector(".search-wrapper"); + isnot(search, null, "Search section should be there."); + let topsites = content.document.querySelector( + "section[data-section-id='topsites']" + ); + isnot(topsites, null, "Top Sites section should be there."); + let highlights = content.document.querySelector( + "section[data-section-id='highlights']" + ); + isnot(highlights, null, "Highlights section should be there."); + }); + BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); +}); + +add_task(async function test_firefox_home_with_policy() { + await SpecialPowers.pushPrefEnv({ + set: [ + [ + "browser.newtabpage.activity-stream.discoverystream.endpointSpocsClear", + "", + ], + ], + }); + + await setupPolicyEngineWithJson({ + policies: { + FirefoxHome: { + Search: false, + TopSites: false, + Highlights: false, + Snippets: false, + }, + }, + }); + + let tab = await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + opening: "about:home", + waitForStateStop: true, + }); + + await SpecialPowers.spawn(tab.linkedBrowser, [], function () { + let search = content.document.querySelector(".search-wrapper"); + is(search, null, "Search section should not be there."); + let topsites = content.document.querySelector( + "section[data-section-id='topsites']" + ); + is(topsites, null, "Top Sites section should not be there."); + let highlights = content.document.querySelector( + "section[data-section-id='highlights']" + ); + is(highlights, null, "Highlights section should not be there."); + }); + BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); +}); + +add_task(async function test_firefoxhome_preferences_set() { + await SpecialPowers.pushPrefEnv({ + set: [ + [ + "browser.newtabpage.activity-stream.discoverystream.endpointSpocsClear", + "", + ], + ], + }); + + await setupPolicyEngineWithJson({ + policies: { + FirefoxHome: { + Search: false, + TopSites: false, + SponsoredTopSites: false, + Highlights: false, + Pocket: false, + SponsoredPocket: false, + Snippets: false, + Locked: true, + }, + }, + }); + + await BrowserTestUtils.withNewTab("about:preferences#home", async browser => { + let data = { + Search: "browser.newtabpage.activity-stream.showSearch", + TopSites: "browser.newtabpage.activity-stream.feeds.topsites", + SponsoredTopSites: + "browser.newtabpage.activity-stream.showSponsoredTopSites", + Highlights: "browser.newtabpage.activity-stream.feeds.section.highlights", + Pocket: "browser.newtabpage.activity-stream.feeds.section.topstories", + SponsoredPocket: "browser.newtabpage.activity-stream.showSponsored", + Snippets: "browser.newtabpage.activity-stream.feeds.snippets", + }; + for (let [section, preference] of Object.entries(data)) { + is( + browser.contentDocument.querySelector( + `checkbox[preference='${preference}']` + ).disabled, + true, + `${section} checkbox should be disabled` + ); + } + }); + await setupPolicyEngineWithJson({ + policies: { + FirefoxHome: {}, + }, + }); + await SpecialPowers.popPrefEnv(); +}); -- cgit v1.2.3