File tree Expand file tree Collapse file tree
browser/components/enterprisepolicies/tests/xpcshell
toolkit/components/enterprisepolicies Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,48 @@ add_task(async function test_extensionsettings() {
120120 ) ;
121121} ) ;
122122
123+ add_task ( async function test_force_installed_updates_disabled ( ) {
124+ await setupPolicyEngineWithJson ( {
125+ policies : {
126+ ExtensionSettings : {
127+ "force@mozilla.com" : {
128+ installation_mode : "force_installed" ,
129+ install_url : "https://example.com/test.xpi" ,
130+ } ,
131+ "force_explicit@mozilla.com" : {
132+ installation_mode : "force_installed" ,
133+ install_url : "https://example.com/test.xpi" ,
134+ updates_disabled : true ,
135+ } ,
136+ "normal@mozilla.com" : {
137+ installation_mode : "normal_installed" ,
138+ install_url : "https://example.com/test.xpi" ,
139+ } ,
140+ } ,
141+ } ,
142+ } ) ;
143+
144+ equal (
145+ Services . policies . getExtensionSettings ( "force@mozilla.com" )
146+ . updates_disabled ,
147+ false ,
148+ "force_installed with no updates_disabled should default to false"
149+ ) ;
150+ equal (
151+ Services . policies . getExtensionSettings ( "force_explicit@mozilla.com" )
152+ . updates_disabled ,
153+ true ,
154+ "force_installed with explicit updates_disabled: true should be respected"
155+ ) ;
156+ ok (
157+ ! (
158+ "updates_disabled" in
159+ Services . policies . getExtensionSettings ( "normal@mozilla.com" )
160+ ) ,
161+ "non-force_installed should not synthesize updates_disabled"
162+ ) ;
163+ } ) ;
164+
123165add_task ( async function test_addon_blocked ( ) {
124166 await setupPolicyEngineWithJson ( {
125167 policies : {
Original file line number Diff line number Diff line change @@ -426,15 +426,23 @@ EnterprisePoliciesManager.prototype = {
426426 } ,
427427
428428 getExtensionSettings ( extensionID ) {
429- let settings = null ;
430- if ( ExtensionSettings ) {
431- if ( extensionID in ExtensionSettings ) {
432- settings = ExtensionSettings [ extensionID ] ;
433- } else if ( "*" in ExtensionSettings ) {
434- settings = ExtensionSettings [ "*" ] ;
429+ if ( ! ExtensionSettings ) {
430+ return null ;
431+ }
432+ if ( extensionID in ExtensionSettings ) {
433+ const settings = ExtensionSettings [ extensionID ] ;
434+ if (
435+ settings . installation_mode === "force_installed" &&
436+ ! ( "updates_disabled" in settings )
437+ ) {
438+ return { ...settings , updates_disabled : false } ;
435439 }
440+ return settings ;
436441 }
437- return settings ;
442+ if ( "*" in ExtensionSettings ) {
443+ return ExtensionSettings [ "*" ] ;
444+ }
445+ return null ;
438446 } ,
439447
440448 isAddonRequiredByPolicy ( addonID ) {
You can’t perform that action at this time.
0 commit comments