1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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();
});
|