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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const HOMEPAGE_PREF = "browser.startup.homepage";
const NEWTAB_PREF = "browser.newtabpage.enabled";
const HIGHLIGHTS_PREF =
"browser.newtabpage.activity-stream.feeds.section.highlights";
const HIGHLIGHTS_ROWS_PREF =
"browser.newtabpage.activity-stream.section.highlights.rows";
const SEARCH_PREF = "browser.newtabpage.activity-stream.showSearch";
const TOPSITES_PREF = "browser.newtabpage.activity-stream.feeds.topsites";
const SNIPPETS_PREF = "browser.newtabpage.activity-stream.feeds.snippets";
const TOPSTORIES_PREF =
"browser.newtabpage.activity-stream.feeds.system.topstories";
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
// Highlights are preffed off by default.
set: [
[HIGHLIGHTS_PREF, true],
[
"browser.newtabpage.activity-stream.discoverystream.endpointSpocsClear",
"",
],
],
});
registerCleanupFunction(async () => {
await SpecialPowers.popPrefEnv();
[
HOMEPAGE_PREF,
NEWTAB_PREF,
HIGHLIGHTS_PREF,
HIGHLIGHTS_ROWS_PREF,
SEARCH_PREF,
TOPSITES_PREF,
SNIPPETS_PREF,
].forEach(prefName => Services.prefs.clearUserPref(prefName));
});
});
add_task(async function test_CONFIGURE_HOMEPAGE_newtab_home_prefs() {
const action = {
type: "CONFIGURE_HOMEPAGE",
data: { homePage: "default", newtab: "default" },
};
await SpecialPowers.pushPrefEnv({
set: [
[HOMEPAGE_PREF, "about:blank"],
[NEWTAB_PREF, false],
],
});
Assert.ok(Services.prefs.prefHasUserValue(HOMEPAGE_PREF), "Test setup ok");
Assert.ok(Services.prefs.prefHasUserValue(NEWTAB_PREF), "Test setup ok");
await SMATestUtils.executeAndValidateAction(action);
Assert.ok(
!Services.prefs.prefHasUserValue(HOMEPAGE_PREF),
"Homepage pref should be back to default"
);
Assert.ok(
!Services.prefs.prefHasUserValue(NEWTAB_PREF),
"Newtab pref should be back to default"
);
});
add_task(async function test_CONFIGURE_HOMEPAGE_layout_prefs() {
const action = {
type: "CONFIGURE_HOMEPAGE",
data: {
layout: {
search: true,
topsites: false,
highlights: false,
snippets: false,
topstories: false,
},
},
};
await SpecialPowers.pushPrefEnv({
set: [
[HIGHLIGHTS_ROWS_PREF, 3],
[SEARCH_PREF, false],
],
});
await SMATestUtils.executeAndValidateAction(action);
Assert.ok(Services.prefs.getBoolPref(SEARCH_PREF), "Search is turned on");
Assert.ok(
!Services.prefs.getBoolPref(TOPSITES_PREF),
"Topsites are turned off"
);
Assert.ok(
Services.prefs.getBoolPref(HIGHLIGHTS_PREF),
"HIGHLIGHTS_PREF are on because they have been customized"
);
Assert.ok(
!Services.prefs.getBoolPref(TOPSTORIES_PREF),
"Topstories are turned off"
);
Assert.ok(
!Services.prefs.getBoolPref(SNIPPETS_PREF),
"Snippets are turned off"
);
});
|