diff --git a/atom/browser/api/atom_api_system_preferences.cc b/atom/browser/api/atom_api_system_preferences.cc index 2b11aad25278..8a02859f2970 100644 --- a/atom/browser/api/atom_api_system_preferences.cc +++ b/atom/browser/api/atom_api_system_preferences.cc @@ -54,6 +54,7 @@ void SystemPreferences::BuildPrototype( .SetMethod("unsubscribeNotification", &SystemPreferences::UnsubscribeNotification) .SetMethod("getUserDefault", &SystemPreferences::GetUserDefault) + .SetMethod("getGlobalDefault", &SystemPreferences::GetGlobalDefault) #endif .SetMethod("isDarkMode", &SystemPreferences::IsDarkMode); } diff --git a/spec/api-system-preferences-spec.js b/spec/api-system-preferences-spec.js new file mode 100644 index 000000000000..3cb0cd406660 --- /dev/null +++ b/spec/api-system-preferences-spec.js @@ -0,0 +1,25 @@ +const assert = require('assert') +const {remote} = require('electron') +const {systemPreferences} = remote + +describe('systemPreferences module', function () { + if (process.platform !== 'darwin') { + return + } + + it('returns user defaults', function () { + assert.notEqual(systemPreferences.getUserDefault('AppleInterfaceStyle', 'string'), null) + assert.notEqual(systemPreferences.getUserDefault('AppleAquaColorVariant', 'integer'), null) + }) + + it('returns defaults under the global domain', function () { + let locale = systemPreferences.getGlobalDefault('AppleLocale') + assert.notEqual(locale, null) + assert(locale.length > 0) + + let languages = systemPreferences.getGlobalDefault('AppleLanguages') + assert.notEqual(languages, null) + assert(languages.length > 0) + }) + +})