Bug 1375133 - Remove unnecessary imports of btoa and atob in services/ code. r=markh draft
authorAndrew McCreight <continuation@gmail.com>
Wed, 21 Jun 2017 09:56:57 -0700
changeset 598534 9b0c94227ca267005fe3c54c9f5b8ae33518aa9f
parent 598533 035f44f56e0e83a169294e1d0220af6879327a55
child 634497 6fc06e2eb46d93ecc5499aadc930dbb59c3f8602
push id65227
push userbmo:continuation@gmail.com
push dateWed, 21 Jun 2017 19:49:08 +0000
reviewersmarkh
bugs1375133, 937114
milestone56.0a1
Bug 1375133 - Remove unnecessary imports of btoa and atob in services/ code. r=markh There are a few places in services/ tests that import btoa and atob, but this is not necessary, because those are both defined on the XPCShell global (by glob_functions in XPCShellImpl.cpp). It sounds like it didn't work at some point on B2G (see bug 937114) but that isn't relevant any more. I want to fix this because the way these properties are imported will break with shared JSM globals. MozReview-Commit-ID: HoxqIS98p7B
services/common/tests/unit/head_helpers.js
services/crypto/tests/unit/test_utils_pbkdf2.js
services/fxaccounts/tests/xpcshell/test_accounts.js
services/sync/modules-testing/fakeservices.js
services/sync/modules-testing/utils.js
--- a/services/common/tests/unit/head_helpers.js
+++ b/services/common/tests/unit/head_helpers.js
@@ -5,19 +5,16 @@
 /* import-globals-from head_global.js */
 
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://services-common/utils.js");
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://testing-common/services/common/logging.js");
 Cu.import("resource://testing-common/MockRegistrar.jsm");
 
-var btoa = Cu.import("resource://gre/modules/Log.jsm").btoa;
-var atob = Cu.import("resource://gre/modules/Log.jsm").atob;
-
 function do_check_empty(obj) {
   do_check_attribute_count(obj, 0);
 }
 
 function do_check_attribute_count(obj, c) {
   do_check_eq(c, Object.keys(obj).length);
 }
 
--- a/services/crypto/tests/unit/test_utils_pbkdf2.js
+++ b/services/crypto/tests/unit/test_utils_pbkdf2.js
@@ -1,13 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// XXX until bug 937114 is fixed
-Cu.importGlobalProperties(["btoa"]);
 Cu.import("resource://services-crypto/utils.js");
 Cu.import("resource://services-common/utils.js");
 
 var {bytesAsHex: b2h} = CommonUtils;
 
 function run_test() {
   run_next_test();
 }
--- a/services/fxaccounts/tests/xpcshell/test_accounts.js
+++ b/services/fxaccounts/tests/xpcshell/test_accounts.js
@@ -15,19 +15,16 @@ Cu.import("resource://gre/modules/Log.js
 var {AccountState} = Cu.import("resource://gre/modules/FxAccounts.jsm", {});
 
 const ONE_HOUR_MS = 1000 * 60 * 60;
 const ONE_DAY_MS = ONE_HOUR_MS * 24;
 const TWO_MINUTES_MS = 1000 * 60 * 2;
 
 initTestLogging("Trace");
 
-// XXX until bug 937114 is fixed
-Cu.importGlobalProperties(["atob"]);
-
 var log = Log.repository.getLogger("Services.FxAccounts.test");
 log.level = Log.Level.Debug;
 
 // See verbose logging from FxAccounts.jsm and jwcrypto.jsm.
 Services.prefs.setCharPref("identity.fxaccounts.loglevel", "Trace");
 Log.repository.getLogger("FirefoxAccounts").level = Log.Level.Trace;
 Services.prefs.setCharPref("services.crypto.jwcrypto.log.level", "Debug");
 
--- a/services/sync/modules-testing/fakeservices.js
+++ b/services/sync/modules-testing/fakeservices.js
@@ -12,18 +12,16 @@ this.EXPORTED_SYMBOLS = [
 ];
 
 var {utils: Cu} = Components;
 
 Cu.import("resource://services-sync/main.js");
 Cu.import("resource://services-sync/record.js");
 Cu.import("resource://services-sync/util.js");
 
-var btoa = Cu.import("resource://gre/modules/Log.jsm").btoa;
-
 this.FakeFilesystemService = function FakeFilesystemService(contents) {
   this.fakeContents = contents;
   let self = this;
 
   // Save away the unmocked versions of the functions we replace here for tests
   // that really want the originals. As this may be called many times per test,
   // we must be careful to not replace them with ones we previously replaced.
   // (And WTF are we bothering with these mocks in the first place? Is the
--- a/services/sync/modules-testing/utils.js
+++ b/services/sync/modules-testing/utils.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
-  "btoa", // It comes from a module import.
   "encryptPayload",
   "makeIdentityConfig",
   "makeFxAccountsInternalMock",
   "configureFxAccountIdentity",
   "configureIdentity",
   "SyncTestingInfrastructure",
   "waitForZeroTimer",
   "promiseZeroTimer",