diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js')
-rw-r--r-- | browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js | 129 |
1 files changed, 129 insertions, 0 deletions
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..b1b269451b --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxhome.js @@ -0,0 +1,129 @@ +/* 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, + }, + }, + }); + + 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, + 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", + }; + 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(); +}); |