Bug 1082843. Don't import Promise.jsm into the global scope in xpcshell tests. r=yoric
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 15 Oct 2014 00:42:54 -0400
changeset 210493 d343b4bb2bc080c66825e41069121a7b4e80c785
parent 210492 8ec4cf432cd8d0f5f174df08c5510ac8f90a12df
child 210494 869f6077817ac69640053331fbeadb0342330781
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersyoric
bugs1082843
milestone36.0a1
Bug 1082843. Don't import Promise.jsm into the global scope in xpcshell tests. r=yoric
browser/components/loop/test/xpcshell/head.js
extensions/cookie/test/unit/test_permmanager_defaults.js
testing/xpcshell/head.js
toolkit/modules/tests/xpcshell/test_sqlite_shutdown.js
--- a/browser/components/loop/test/xpcshell/head.js
+++ b/browser/components/loop/test/xpcshell/head.js
@@ -3,16 +3,17 @@
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Http.jsm");
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource:///modules/loop/MozLoopService.jsm");
+Cu.import("resource://gre/modules/Promise.jsm");
 const { MozLoopServiceInternal } = Cu.import("resource:///modules/loop/MozLoopService.jsm", {});
 
 XPCOMUtils.defineLazyModuleGetter(this, "MozLoopPushHandler",
                                   "resource:///modules/loop/MozLoopPushHandler.jsm");
 
 const kMockWebSocketChannelName = "Mock WebSocket Channel";
 const kWebSocketChannelContractID = "@mozilla.org/network/protocol;1?name=wss";
 
--- a/extensions/cookie/test/unit/test_permmanager_defaults.js
+++ b/extensions/cookie/test/unit/test_permmanager_defaults.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // The origin we use in most of the tests.
 const TEST_ORIGIN = "example.org";
 const TEST_ORIGIN_2 = "example.com";
 const TEST_PERMISSION = "test-permission";
+Components.utils.import("resource://gre/modules/Promise.jsm");
 
 function promiseTimeout(delay) {
   let deferred = Promise.defer();
   do_timeout(delay, deferred.resolve);
   return deferred.promise;
 }
 
 function run_test() {
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -18,17 +18,17 @@ var _todoChecks = 0;
 var _cleanupFunctions = [];
 var _pendingTimers = [];
 var _profileInitialized = false;
 
 // Register the testing-common resource protocol early, to have access to its
 // modules.
 _register_modules_protocol_handler();
 
-let _Promise = Components.utils.import("resource://gre/modules/Promise.jsm", this).Promise;
+let _Promise = Components.utils.import("resource://gre/modules/Promise.jsm", {}).Promise;
 
 // Support a common assertion library, Assert.jsm.
 let AssertCls = Components.utils.import("resource://testing-common/Assert.jsm", null).Assert;
 // Pass a custom report function for xpcshell-test style reporting.
 let Assert = new AssertCls(function(err, message, stack) {
   if (err) {
     do_report_result(false, err.message, err.stack);
   } else {
--- a/toolkit/modules/tests/xpcshell/test_sqlite_shutdown.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite_shutdown.js
@@ -8,16 +8,17 @@ const {classes: Cc, interfaces: Ci, util
 do_get_profile();
 
 Cu.import("resource://gre/modules/osfile.jsm");
   // OS.File doesn't like to be first imported during shutdown
 Cu.import("resource://gre/modules/Sqlite.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/AsyncShutdown.jsm");
+Cu.import("resource://gre/modules/Promise.jsm");
 
 function getConnection(dbName, extraOptions={}) {
   let path = dbName + ".sqlite";
   let options = {path: path};
   for (let [k, v] in Iterator(extraOptions)) {
     options[k] = v;
   }