Bug 1267849 - Call LoginManagerParent.init in setupParent of tests. r=dolske draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 02 Aug 2016 15:00:52 -0700
changeset 395794 779f40e9887b675d032fdc24c5c5b490d08b65f4
parent 395769 edd81b946037e7773e3d8b358a211baa3c4ef463
child 527063 5e2e153dc90582b767dcba8a6d33b98a14948c2f
push id24848
push usermozilla@noorenberghe.ca
push dateTue, 02 Aug 2016 22:01:09 +0000
reviewersdolske
bugs1267849
milestone51.0a1
Bug 1267849 - Call LoginManagerParent.init in setupParent of tests. r=dolske MozReview-Commit-ID: 66FZogdR6Ve
toolkit/components/passwordmgr/test/pwmgr_common.js
--- a/toolkit/components/passwordmgr/test/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/pwmgr_common.js
@@ -355,41 +355,45 @@ function runChecksAfterCommonInit(aFunct
 if (this.addMessageListener) {
   const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
   var SpecialPowers = { Cc, Ci, Cr, Cu, };
   var ok, is;
   // Ignore ok/is in commonInit since they aren't defined in a chrome script.
   ok = is = () => {}; // eslint-disable-line no-native-reassign
 
   Cu.import("resource://gre/modules/LoginHelper.jsm");
+  Cu.import("resource://gre/modules/LoginManagerParent.jsm");
   Cu.import("resource://gre/modules/Services.jsm");
   Cu.import("resource://gre/modules/Task.jsm");
 
   function onStorageChanged(subject, topic, data) {
     sendAsyncMessage("storageChanged", {
       topic,
       data,
     });
   }
   Services.obs.addObserver(onStorageChanged, "passwordmgr-storage-changed", false);
 
   addMessageListener("setupParent", ({selfFilling = false} = {selfFilling: false}) => {
+    // Force LoginManagerParent to init for the tests since it's normally delayed
+    // by apps such as on Android.
+    LoginManagerParent.init();
+
     commonInit(selfFilling);
     sendAsyncMessage("doneSetup");
   });
 
   addMessageListener("loadRecipes", Task.async(function* loadRecipes(recipes) {
-    var { LoginManagerParent } = Cu.import("resource://gre/modules/LoginManagerParent.jsm", {});
+
     var recipeParent = yield LoginManagerParent.recipeParentPromise;
     yield recipeParent.load(recipes);
     sendAsyncMessage("loadedRecipes", recipes);
   }));
 
   addMessageListener("resetRecipes", Task.async(function* resetRecipes() {
-    let { LoginManagerParent } = Cu.import("resource://gre/modules/LoginManagerParent.jsm", {});
     let recipeParent = yield LoginManagerParent.recipeParentPromise;
     yield recipeParent.reset();
     sendAsyncMessage("recipesReset");
   }));
 
   addMessageListener("proxyLoginManager", msg => {
     // Recreate nsILoginInfo objects from vanilla JS objects.
     let recreatedArgs = msg.args.map((arg, index) => {