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
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
registerCleanupFunction(function restore_pref_values() {
// These two prefs are set as user prefs in case the "Locked"
// option from this policy was not used. In this case, it won't
// be tracked nor restored by the PoliciesPrefTracker.
Services.prefs.clearUserPref("browser.startup.homepage");
});
add_task(async function homepage_test_simple() {
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example1.com/",
},
},
});
await check_homepage({ expectedURL: "http://example1.com/" });
});
add_task(async function homepage_test_repeat_same_policy_value() {
// Simulate homepage change after policy applied
Services.prefs.setStringPref(
"browser.startup.homepage",
"http://example2.com/"
);
Services.prefs.setIntPref("browser.startup.page", 3);
// Policy should have no effect. Homepage has not been locked and policy value
// has not changed. We should be respecting the homepage that the user gave.
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example1.com/",
},
},
});
await check_homepage({
expectedURL: "http://example2.com/",
expectedPageVal: 3,
});
Services.prefs.clearUserPref("browser.startup.page");
Services.prefs.clearUserPref("browser.startup.homepage");
});
add_task(async function homepage_test_empty_additional() {
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example1.com/",
Additional: [],
},
},
});
await check_homepage({ expectedURL: "http://example1.com/" });
});
add_task(async function homepage_test_single_additional() {
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example1.com/",
Additional: ["http://example2.com/"],
},
},
});
await check_homepage({
expectedURL: "http://example1.com/|http://example2.com/",
});
});
add_task(async function homepage_test_multiple_additional() {
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example1.com/",
Additional: ["http://example2.com/", "http://example3.com/"],
},
},
});
await check_homepage({
expectedURL:
"http://example1.com/|http://example2.com/|http://example3.com/",
});
});
add_task(async function homepage_test_locked() {
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example4.com/",
Additional: ["http://example5.com/", "http://example6.com/"],
Locked: true,
},
},
});
await check_homepage({
expectedURL:
"http://example4.com/|http://example5.com/|http://example6.com/",
locked: true,
});
});
add_task(async function homepage_test_anchor_link() {
await setupPolicyEngineWithJson({
policies: {
Homepage: {
URL: "http://example1.com/#test",
},
},
});
await check_homepage({ expectedURL: "http://example1.com/#test" });
});
|