Bug 1389999 - Check the existence of ProfileStorage before running tests in test_refresh_firefox.py. r=MattN, a=test-only
authorLuke Chang <lchang@mozilla.com>
Thu, 24 Aug 2017 14:53:02 +0800
changeset 423798 54f1be40a3552ddc1e565692b87df800c4bb25f4
parent 423797 1a967f2b979606a1dd9802c946c8bea30ae04165
child 423799 ad0fc3b76a90ef8e3b0ab9ffe9eacbeb0750a3ce
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, test-only
bugs1389999
milestone56.0
Bug 1389999 - Check the existence of ProfileStorage before running tests in test_refresh_firefox.py. r=MattN, a=test-only 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)