Bug 1389999 - Check the existence of ProfileStorage before running tests in test_refresh_firefox.py. r=MattN draft
authorLuke Chang <lchang@mozilla.com>
Thu, 24 Aug 2017 14:53:02 +0800
changeset 651916 787bab1841d8c6b77030c63121d58c4285cdad0f
parent 651826 d1c70c20e7b52f7295411343e4dc5db8ee7c92b9
child 727914 2dcaeb4b3a797f7d8a4b0c654c8f9bc5a2922677
push id75867
push userbmo:lchang@mozilla.com
push dateThu, 24 Aug 2017 06:55:02 +0000
reviewersMattN
bugs1389999
milestone57.0a1
Bug 1389999 - Check the existence of ProfileStorage before running tests in test_refresh_firefox.py. r=MattN MozReview-Commit-ID: B0DtEZD3We1
browser/components/migration/tests/marionette/test_refresh_firefox.py
--- a/browser/components/migration/tests/marionette/test_refresh_firefox.py
+++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py
@@ -20,16 +20,17 @@ class TestFirefoxRefresh(MarionetteTestC
     _cookieValue = "some cookie value"
 
     _historyURL = "http://firefox-refresh.marionette-test.mozilla.org/"
     _historyTitle = "Test visit for Firefox Reset"
 
     _formHistoryFieldName = "some-very-unique-marionette-only-firefox-reset-field"
     _formHistoryValue = "special-pumpkin-value"
 
+    _formAutofillAvailable = False
     _formAutofillAddressGuid = None
 
     _expectedURLs = ["about:robots", "about:mozilla"]
 
     def savePassword(self):
         self.runCode("""
           let myLogin = new global.LoginInfo(
             "test.marionette.mozilla.com",
@@ -99,16 +100,18 @@ class TestFirefoxRefresh(MarionetteTestC
               }
             }
           });
         """, script_args=(self._formHistoryFieldName, self._formHistoryValue))
         if error:
           print error
 
     def createFormAutofill(self):
+        if not self._formAutofillAvailable:
+            return
         self._formAutofillAddressGuid = self.runAsyncCode("""
           const TEST_ADDRESS_1 = {
             "given-name": "John",
             "additional-name": "R.",
             "family-name": "Smith",
             organization: "World Wide Web Consortium",
             "street-address": "32 Vassar Street\\\nMIT Room 32-G524",
             "address-level2": "Cambridge",
@@ -243,16 +246,19 @@ class TestFirefoxRefresh(MarionetteTestC
               marionetteScriptFinished(count);
             },
           };
           global.FormHistory.count({}, callbacks);
         """)
         self.assertEqual(formHistoryCount, 1, "There should be only 1 entry in the form history")
 
     def checkFormAutofill(self):
+        if not self._formAutofillAvailable:
+            return
+
         formAutofillResults = self.runAsyncCode("""
           return global.profileStorage.initialize().then(() => {
             return global.profileStorage.addresses.getAll()
           }).then(marionetteScriptFinished);
         """,)
         if type(formAutofillResults) == str:
             self.fail(formAutofillResults)
             return
@@ -352,17 +358,24 @@ class TestFirefoxRefresh(MarionetteTestC
     def setUpScriptData(self):
         self.marionette.set_context(self.marionette.CONTEXT_CHROME)
         self.runCode("""
           window.global = {};
           global.LoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1", "nsILoginInfo", "init");
           global.profSvc = Cc["@mozilla.org/toolkit/profile-service;1"].getService(Ci.nsIToolkitProfileService);
           global.Preferences = Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences;
           global.FormHistory = Cu.import("resource://gre/modules/FormHistory.jsm", {}).FormHistory;
-          global.profileStorage = Cu.import("resource://formautofill/ProfileStorage.jsm", {}).profileStorage;
+        """)
+        self._formAutofillAvailable = self.runCode("""
+          try {
+            global.profileStorage = Cu.import("resource://formautofill/ProfileStorage.jsm", {}).profileStorage;
+          } catch(e) {
+            return false;
+          }
+          return true;
         """)
 
     def runCode(self, script, *args, **kwargs):
         return self.marionette.execute_script(script,
                                               new_sandbox=False,
                                               sandbox=self._sandbox,
                                               *args,
                                               **kwargs)