Bug 1389999 - Check the existence of ProfileStorage before running tests in test_refresh_firefox.py. r=MattN
MozReview-Commit-ID: B0DtEZD3We1
--- 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)