@@ -8,12 +8,12 @@ const { RecommendedPreferences } = ChromeUtils.importESModule(
8
8
9
9
const COMMON_PREF = "toolkit.startup.max_resumed_crashes" ;
10
10
11
- const MARIONETTE_PREF = "dom.disable_beforeunload" ;
12
- const MARIONETTE_RECOMMENDED_PREFS = new Map ( [ [ MARIONETTE_PREF , true ] ] ) ;
11
+ const PROTOCOL_1_PREF = "dom.disable_beforeunload" ;
12
+ const PROTOCOL_1_RECOMMENDED_PREFS = new Map ( [ [ PROTOCOL_1_PREF , true ] ] ) ;
13
13
14
- const CDP_PREF = "browser.contentblocking.features.standard" ;
15
- const CDP_RECOMMENDED_PREFS = new Map ( [
16
- [ CDP_PREF , "-tp,tpPrivate,cookieBehavior0,-cm,-fp" ] ,
14
+ const PROTOCOL_2_PREF = "browser.contentblocking.features.standard" ;
15
+ const PROTOCOL_2_RECOMMENDED_PREFS = new Map ( [
16
+ [ PROTOCOL_2_PREF , "-tp,tpPrivate,cookieBehavior0,-cm,-fp" ] ,
17
17
] ) ;
18
18
19
19
function cleanup ( ) {
@@ -27,55 +27,62 @@ function cleanup() {
27
27
// - via registerCleanupFunction in case a test crashes/times out
28
28
registerCleanupFunction ( cleanup ) ;
29
29
30
- add_task ( async function test_RecommendedPreferences ( ) {
30
+ add_task ( async function test_multipleClients ( ) {
31
31
info ( "Check initial values for the test preferences" ) ;
32
- checkPreferences ( { cdp : false , common : false , marionette : false } ) ;
32
+ checkPreferences ( { common : false , protocol_1 : false , protocol_2 : false } ) ;
33
33
34
- checkPreferences ( { cdp : false , common : false , marionette : false } ) ;
34
+ checkPreferences ( { common : false , protocol_1 : false , protocol_2 : false } ) ;
35
35
36
- info ( "Apply recommended preferences for a marionette client" ) ;
37
- RecommendedPreferences . applyPreferences ( MARIONETTE_RECOMMENDED_PREFS ) ;
38
- checkPreferences ( { cdp : false , common : true , marionette : true } ) ;
36
+ info ( "Apply recommended preferences for a protocol_1 client" ) ;
37
+ RecommendedPreferences . applyPreferences ( PROTOCOL_1_RECOMMENDED_PREFS ) ;
38
+ checkPreferences ( { common : true , protocol_1 : true , protocol_2 : false } ) ;
39
39
40
- info ( "Apply recommended preferences for a cdp client" ) ;
41
- RecommendedPreferences . applyPreferences ( CDP_RECOMMENDED_PREFS ) ;
42
- checkPreferences ( { cdp : true , common : true , marionette : true } ) ;
40
+ info ( "Apply recommended preferences for a protocol_2 client" ) ;
41
+ RecommendedPreferences . applyPreferences ( PROTOCOL_2_RECOMMENDED_PREFS ) ;
42
+ checkPreferences ( { common : true , protocol_1 : true , protocol_2 : true } ) ;
43
43
44
- info ( "Restore marionette preferences" ) ;
45
- RecommendedPreferences . restorePreferences ( MARIONETTE_RECOMMENDED_PREFS ) ;
46
- checkPreferences ( { cdp : true , common : true , marionette : false } ) ;
44
+ info ( "Restore protocol_1 preferences" ) ;
45
+ RecommendedPreferences . restorePreferences ( PROTOCOL_1_RECOMMENDED_PREFS ) ;
46
+ checkPreferences ( { common : true , protocol_1 : false , protocol_2 : true } ) ;
47
47
48
- info ( "Restore cdp preferences" ) ;
49
- RecommendedPreferences . restorePreferences ( CDP_RECOMMENDED_PREFS ) ;
50
- checkPreferences ( { cdp : false , common : true , marionette : false } ) ;
48
+ info ( "Restore protocol_2 preferences" ) ;
49
+ RecommendedPreferences . restorePreferences ( PROTOCOL_2_RECOMMENDED_PREFS ) ;
50
+ checkPreferences ( { common : true , protocol_1 : false , protocol_2 : false } ) ;
51
51
52
52
info ( "Restore all the altered preferences" ) ;
53
53
RecommendedPreferences . restoreAllPreferences ( ) ;
54
- checkPreferences ( { cdp : false , common : false , marionette : false } ) ;
54
+ checkPreferences ( { common : false , protocol_1 : false , protocol_2 : false } ) ;
55
55
56
56
info ( "Attemps to restore again" ) ;
57
57
RecommendedPreferences . restoreAllPreferences ( ) ;
58
- checkPreferences ( { cdp : false , common : false , marionette : false } ) ;
58
+ checkPreferences ( { common : false , protocol_1 : false , protocol_2 : false } ) ;
59
59
60
60
cleanup ( ) ;
61
61
} ) ;
62
62
63
- add_task ( async function test_RecommendedPreferences_disabled ( ) {
63
+ add_task ( async function test_disabled ( ) {
64
64
info ( "Disable RecommendedPreferences" ) ;
65
65
Services . prefs . setBoolPref ( "remote.prefs.recommended" , false ) ;
66
66
67
67
info ( "Check initial values for the test preferences" ) ;
68
- checkPreferences ( { cdp : false , common : false , marionette : false } ) ;
68
+ checkPreferences ( { common : false , protocol_1 : false , protocol_2 : false } ) ;
69
69
70
70
info ( "Recommended preferences are not applied, applyPreferences is a no-op" ) ;
71
- RecommendedPreferences . applyPreferences ( MARIONETTE_RECOMMENDED_PREFS ) ;
72
- checkPreferences ( { cdp : false , common : false , marionette : false } ) ;
71
+ RecommendedPreferences . applyPreferences ( PROTOCOL_1_RECOMMENDED_PREFS ) ;
72
+ checkPreferences ( { common : false , protocol_1 : false , protocol_2 : false } ) ;
73
+
74
+ cleanup ( ) ;
75
+ } ) ;
76
+
77
+ add_task ( async function test_noCustomPreferences ( ) {
78
+ info ( "Applying preferences without any custom preference should not throw" ) ;
79
+ RecommendedPreferences . applyPreferences ( ) ;
73
80
74
81
cleanup ( ) ;
75
82
} ) ;
76
83
77
84
// Check that protocols can override common preferences.
78
- add_task ( async function test_RecommendedPreferences_override ( ) {
85
+ add_task ( async function test_override ( ) {
79
86
info ( "Make sure the common preference has no user value" ) ;
80
87
Services . prefs . clearUserPref ( COMMON_PREF ) ;
81
88
@@ -94,10 +101,10 @@ add_task(async function test_RecommendedPreferences_override() {
94
101
cleanup ( ) ;
95
102
} ) ;
96
103
97
- function checkPreferences ( { cdp , common , marionette } ) {
104
+ function checkPreferences ( { common , protocol_1 , protocol_2 } ) {
98
105
checkPreference ( COMMON_PREF , { hasValue : common } ) ;
99
- checkPreference ( MARIONETTE_PREF , { hasValue : marionette } ) ;
100
- checkPreference ( CDP_PREF , { hasValue : cdp } ) ;
106
+ checkPreference ( PROTOCOL_1_PREF , { hasValue : protocol_1 } ) ;
107
+ checkPreference ( PROTOCOL_2_PREF , { hasValue : protocol_2 } ) ;
101
108
}
102
109
103
110
function checkPreference ( pref , { hasValue } ) {
0 commit comments