test_accounts_config.js (1409B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { FxAccounts } = ChromeUtils.importESModule( 7 "resource://gre/modules/FxAccounts.sys.mjs" 8 ); 9 10 add_task(async function test_non_https_remote_server_uri() { 11 Services.prefs.setStringPref( 12 "identity.fxaccounts.remote.root", 13 "http://example.com/" 14 ); 15 await Assert.rejects( 16 FxAccounts.config.promiseConnectAccountURI(), 17 /Firefox Accounts server must use HTTPS/ 18 ); 19 Services.prefs.clearUserPref("identity.fxaccounts.remote.root"); 20 }); 21 22 add_task(async function test_is_production_config() { 23 // should start with no auto-config URL. 24 Assert.ok(!FxAccounts.config.getAutoConfigURL()); 25 // which means we are using prod. 26 Assert.ok(FxAccounts.config.isProductionConfig()); 27 28 // Set an auto-config URL. 29 Services.prefs.setStringPref( 30 "identity.fxaccounts.autoconfig.uri", 31 "http://x" 32 ); 33 Assert.equal(FxAccounts.config.getAutoConfigURL(), "http://x"); 34 Assert.ok(!FxAccounts.config.isProductionConfig()); 35 36 // Clear the auto-config URL, but set one of the other config params. 37 Services.prefs.clearUserPref("identity.fxaccounts.autoconfig.uri"); 38 Services.prefs.setStringPref("identity.sync.tokenserver.uri", "http://t"); 39 Assert.ok(!FxAccounts.config.isProductionConfig()); 40 Services.prefs.clearUserPref("identity.sync.tokenserver.uri"); 41 });