@@ -11,27 +11,24 @@ const { AppConstants } = ChromeUtils.importESModule(
1111 "resource://gre/modules/AppConstants.sys.mjs"
1212) ;
1313const {
14- DefaultWindowsLaunchOnLogin ,
15- DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_NIMBUS_FEATURE_ID ,
16- DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_PREF ,
14+ DefaultLaunchOnLogin ,
15+ DEFAULT_LAUNCH_ON_LOGIN_NIMBUS_FEATURE_ID ,
16+ DEFAULT_LAUNCH_ON_LOGIN_PREF ,
1717} = ChromeUtils . importESModule (
18- "resource:///modules/DefaultWindowsLaunchOnLogin .sys.mjs"
18+ "resource:///modules/DefaultLaunchOnLogin .sys.mjs"
1919) ;
20- const { WindowsLaunchOnLogin } = ChromeUtils . importESModule (
21- "resource://gre/modules/WindowsLaunchOnLogin .sys.mjs"
20+ const { LaunchOnLogin } = ChromeUtils . importESModule (
21+ "resource://gre/modules/LaunchOnLogin .sys.mjs"
2222) ;
2323const { NimbusTestUtils } = ChromeUtils . importESModule (
2424 "resource://testing-common/NimbusTestUtils.sys.mjs"
2525) ;
2626const { updateAppInfo } = ChromeUtils . importESModule (
2727 "resource://testing-common/AppInfo.sys.mjs"
2828) ;
29- const { MockRegistry } = ChromeUtils . importESModule (
30- "resource://testing-common/MockRegistry.sys.mjs"
31- ) ;
3229
3330const CATEGORY_NAME = "browser-idle-startup" ;
34- const MODULE_URI = "resource:///modules/DefaultWindowsLaunchOnLogin .sys.mjs" ;
31+ const MODULE_URI = "resource:///modules/DefaultLaunchOnLogin .sys.mjs" ;
3532
3633NimbusTestUtils . init ( this ) ;
3734
@@ -40,22 +37,6 @@ add_setup(async () => {
4037 // FOG needs a profile
4138 do_get_profile ( ) ;
4239
43- registry = new MockRegistry ( ) ;
44-
45- // It's expected that these keys exist
46- registry . setValue (
47- Ci . nsIWindowsRegKey . ROOT_KEY_CURRENT_USER ,
48- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" ,
49- "" ,
50- ""
51- ) ;
52- registry . setValue (
53- Ci . nsIWindowsRegKey . ROOT_KEY_CURRENT_USER ,
54- "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartupApproved\\Run" ,
55- "" ,
56- ""
57- ) ;
58-
5940 Services . fog . initializeFOG ( ) ;
6041 Services . fog . testResetFOG ( ) ;
6142 updateAppInfo ( ) ;
@@ -64,12 +45,11 @@ add_setup(async () => {
6445
6546 registerCleanupFunction ( ( ) => {
6647 nimbusTestCleanup ( ) ;
67- registry . shutdown ( ) ;
6848 } ) ;
6949} ) ;
7050
7151// Runs enableOnFirstRunIfNeeded with the Nimbus wait stubbed out and the
72- // WindowsLaunchOnLogin side effects stubbed. Sets the defaultEnabled pref to
52+ // LaunchOnLogin side effects stubbed. Sets the defaultEnabled pref to
7353// prefValue -- in production Nimbus writes that pref via setPref, so driving the
7454// pref directly exercises the module's decision logic; the Nimbus -> pref
7555// linkage is covered separately by test_nimbus_enrollment_sets_pref.
@@ -81,62 +61,60 @@ async function runWith(
8161 prefValue
8262) {
8363 let sandbox = sinon . createSandbox ( ) ;
84- sandbox . stub ( DefaultWindowsLaunchOnLogin , "waitForNimbusReady" ) . resolves ( ) ;
64+ sandbox . stub ( DefaultLaunchOnLogin , "waitForNimbusReady" ) . resolves ( ) ;
8565 let approvedStub = sandbox
86- . stub ( WindowsLaunchOnLogin , "getLaunchOnLoginApproved " )
66+ . stub ( LaunchOnLogin , "isAllowed " )
8767 . resolves ( approved ) ;
88- let createStub = sandbox
89- . stub ( WindowsLaunchOnLogin , "createLaunchOnLogin" )
90- . resolves ( ) ;
68+ let createStub = sandbox . stub ( LaunchOnLogin , "enable" ) . resolves ( ) ;
9169
92- Services . prefs . setBoolPref ( DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_PREF , prefValue ) ;
70+ Services . prefs . setBoolPref ( DEFAULT_LAUNCH_ON_LOGIN_PREF , prefValue ) ;
9371
9472 try {
95- await DefaultWindowsLaunchOnLogin . enableOnFirstRunIfNeeded (
73+ await DefaultLaunchOnLogin . enableOnFirstRunIfNeeded (
9674 isFirstRun ,
9775 isOfficialBuild ,
9876 alreadyApplied
9977 ) ;
10078 return { approvedStub, createStub } ;
10179 } finally {
10280 sandbox . restore ( ) ;
103- Services . prefs . clearUserPref ( DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_PREF ) ;
81+ Services . prefs . clearUserPref ( DEFAULT_LAUNCH_ON_LOGIN_PREF ) ;
10482 }
10583}
10684
10785add_task ( async function test_is_registered_in_idle_startup ( ) {
10886 const entry = Services . catMan . getCategoryEntry ( CATEGORY_NAME , MODULE_URI ) ;
10987 Assert . equal (
11088 entry ,
111- "DefaultWindowsLaunchOnLogin .maybeEnableOnFirstRun" ,
89+ "DefaultLaunchOnLogin .maybeEnableOnFirstRun" ,
11290 "Entry should point to `maybeEnableOnFirstRun` in `browser-idle-startup`"
11391 ) ;
11492} ) ;
11593
11694add_task (
11795 {
11896 skip_if : ( ) =>
119- ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "win " ,
97+ ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "linux " ,
12098 } ,
12199 async function test_disabled_when_pref_off ( ) {
122100 let { createStub } = await runWith ( true , true , true , false , false ) ;
123101 Assert . ok (
124102 ! createStub . called ,
125- "createLaunchOnLogin should not be called when the pref is off"
103+ "LaunchOnLogin.enable should not be called when the pref is off"
126104 ) ;
127105 }
128106) ;
129107
130108add_task (
131109 {
132110 skip_if : ( ) =>
133- ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "win " ,
111+ ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "linux " ,
134112 } ,
135113 async function test_enabled_when_pref_on ( ) {
136114 let { createStub } = await runWith ( true , true , true , false , true ) ;
137115 Assert . ok (
138116 createStub . calledOnce ,
139- "createLaunchOnLogin should be called when the pref is on"
117+ "LaunchOnLogin.enable should be called when the pref is on"
140118 ) ;
141119 }
142120) ;
@@ -146,31 +124,31 @@ add_task(
146124add_task (
147125 {
148126 skip_if : ( ) =>
149- ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "win " ,
127+ ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "linux " ,
150128 } ,
151129 async function test_nimbus_enrollment_sets_pref ( ) {
152130 let cleanup = await NimbusTestUtils . enrollWithFeatureConfig (
153131 {
154- featureId : DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_NIMBUS_FEATURE_ID ,
132+ featureId : DEFAULT_LAUNCH_ON_LOGIN_NIMBUS_FEATURE_ID ,
155133 value : { enabled : true } ,
156134 } ,
157135 { isRollout : true }
158136 ) ;
159137 Assert . ok (
160- Services . prefs . getBoolPref ( DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_PREF , false ) ,
138+ Services . prefs . getBoolPref ( DEFAULT_LAUNCH_ON_LOGIN_PREF , false ) ,
161139 "enrolling with enabled:true sets the defaultEnabled pref to true"
162140 ) ;
163141 await cleanup ( ) ;
164142
165143 cleanup = await NimbusTestUtils . enrollWithFeatureConfig (
166144 {
167- featureId : DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_NIMBUS_FEATURE_ID ,
145+ featureId : DEFAULT_LAUNCH_ON_LOGIN_NIMBUS_FEATURE_ID ,
168146 value : { enabled : false } ,
169147 } ,
170148 { isRollout : true }
171149 ) ;
172150 Assert . ok (
173- ! Services . prefs . getBoolPref ( DEFAULT_WINDOWS_LAUNCH_ON_LOGIN_PREF , true ) ,
151+ ! Services . prefs . getBoolPref ( DEFAULT_LAUNCH_ON_LOGIN_PREF , true ) ,
174152 "enrolling with enabled:false sets the defaultEnabled pref to false"
175153 ) ;
176154 await cleanup ( ) ;
@@ -181,22 +159,22 @@ add_task(async function test_skips_when_not_first_run() {
181159 let { createStub } = await runWith ( false , true , true , false , true ) ;
182160 Assert . ok (
183161 ! createStub . called ,
184- "createLaunchOnLogin should not be called when isFirstRun is false"
162+ "LaunchOnLogin.enable should not be called when isFirstRun is false"
185163 ) ;
186164} ) ;
187165
188166add_task ( async function test_skips_on_unofficial_build ( ) {
189167 let { createStub } = await runWith ( true , false , true , false , true ) ;
190168 Assert . ok (
191169 ! createStub . called ,
192- "createLaunchOnLogin should not be called on developer builds"
170+ "LaunchOnLogin.enable should not be called on developer builds"
193171 ) ;
194172} ) ;
195173
196174add_task (
197175 {
198176 skip_if : ( ) =>
199- ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "win " ,
177+ ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "linux " ,
200178 } ,
201179 async function test_skips_when_windows_policy_denies ( ) {
202180 let { createStub, approvedStub } = await runWith (
@@ -212,15 +190,15 @@ add_task(
212190 ) ;
213191 Assert . ok (
214192 ! createStub . called ,
215- "createLaunchOnLogin should not be called when Windows policy denies"
193+ "LaunchOnLogin should not be called when Windows policy denies"
216194 ) ;
217195 }
218196) ;
219197
220198add_task (
221199 {
222200 skip_if : ( ) =>
223- ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "win " ,
201+ ! AppConstants . MOZ_NORMANDY || AppConstants . platform !== "linux " ,
224202 } ,
225203 async function test_skips_when_already_applied ( ) {
226204 let { createStub, approvedStub } = await runWith (
@@ -237,7 +215,7 @@ add_task(
237215
238216 Assert . ok (
239217 ! createStub . called ,
240- "createLaunchOnLogin should not be called when already applied is true"
218+ "LaunchOnLogin.enable should not be called when already applied is true"
241219 ) ;
242220 }
243221) ;
0 commit comments