mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Bug 1416377 - Use new async Places APIs in test_refresh_firefox.py. r=standard8
MozReview-Commit-ID: HvN8oHgIbbq --HG-- extra : rebase_source : 5a21dba36985008f5383ed6332571f91565716a5
This commit is contained in:
parent
19b51b0b4c
commit
04c132a988
@ -45,45 +45,41 @@ class TestFirefoxRefresh(MarionetteTestCase):
|
|||||||
""", script_args=(self._username, self._password))
|
""", script_args=(self._username, self._password))
|
||||||
|
|
||||||
def createBookmarkInMenu(self):
|
def createBookmarkInMenu(self):
|
||||||
self.marionette.execute_script("""
|
error = self.runAsyncCode("""
|
||||||
let url = arguments[0];
|
let url = arguments[0];
|
||||||
let title = arguments[1];
|
let title = arguments[1];
|
||||||
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.bookmarksMenuFolder,
|
PlacesUtils.bookmarks.insert({
|
||||||
makeURI(url), 0, title);
|
parentGuid: PlacesUtils.bookmarks.menuGuid, url, title
|
||||||
|
}).then(() => marionetteScriptFinished(false), marionetteScriptFinished);
|
||||||
""", script_args=(self._bookmarkURL, self._bookmarkText))
|
""", script_args=(self._bookmarkURL, self._bookmarkText))
|
||||||
|
if error:
|
||||||
|
print error
|
||||||
|
|
||||||
def createBookmarksOnToolbar(self):
|
def createBookmarksOnToolbar(self):
|
||||||
self.marionette.execute_script("""
|
error = self.runAsyncCode("""
|
||||||
|
let children = [];
|
||||||
for (let i = 1; i <= 5; i++) {
|
for (let i = 1; i <= 5; i++) {
|
||||||
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.toolbarFolderId,
|
children.push({url: `about:rights?p=${i}`, title: `Bookmark ${i}`});
|
||||||
makeURI(`about:rights?p=${i}`), 0, `Bookmark ${i}`);
|
|
||||||
}
|
}
|
||||||
|
PlacesUtils.bookmarks.insertTree({
|
||||||
|
guid: PlacesUtils.bookmarks.toolbarGuid,
|
||||||
|
children
|
||||||
|
}).then(() => marionetteScriptFinished(false), marionetteScriptFinished);
|
||||||
""")
|
""")
|
||||||
|
if error:
|
||||||
|
print error
|
||||||
|
|
||||||
def createHistory(self):
|
def createHistory(self):
|
||||||
error = self.runAsyncCode("""
|
error = self.runAsyncCode("""
|
||||||
// Copied from PlacesTestUtils, which isn't available in Marionette tests.
|
PlacesUtils.history.insert({
|
||||||
let didReturn;
|
url: arguments[0],
|
||||||
PlacesUtils.asyncHistory.updatePlaces(
|
title: arguments[1],
|
||||||
[{title: arguments[1], uri: makeURI(arguments[0]), visits: [{
|
visits: [{
|
||||||
transitionType: Ci.nsINavHistoryService.TRANSITION_LINK,
|
date: new Date(Date.now() - 5000),
|
||||||
visitDate: (Date.now() - 5000) * 1000,
|
referrer: "about:mozilla"
|
||||||
referrerURI: makeURI("about:mozilla"),
|
}]
|
||||||
}]
|
}).then(() => marionetteScriptFinished(false),
|
||||||
}],
|
ex => marionetteScriptFinished("Unexpected error in adding visit: " + ex));
|
||||||
{
|
|
||||||
handleError(resultCode, place) {
|
|
||||||
didReturn = true;
|
|
||||||
marionetteScriptFinished("Unexpected error in adding visit: " + resultCode);
|
|
||||||
},
|
|
||||||
handleResult() {},
|
|
||||||
handleCompletion() {
|
|
||||||
if (!didReturn) {
|
|
||||||
marionetteScriptFinished(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
""", script_args=(self._historyURL, self._historyTitle))
|
""", script_args=(self._historyURL, self._historyTitle))
|
||||||
if error:
|
if error:
|
||||||
print error
|
print error
|
||||||
@ -209,10 +205,12 @@ class TestFirefoxRefresh(MarionetteTestCase):
|
|||||||
self.assertEqual(loginCount, 2, "No other logins are present")
|
self.assertEqual(loginCount, 2, "No other logins are present")
|
||||||
|
|
||||||
def checkBookmarkInMenu(self):
|
def checkBookmarkInMenu(self):
|
||||||
titleInBookmarks = self.marionette.execute_script("""
|
titleInBookmarks = self.runAsyncCode("""
|
||||||
let url = arguments[0];
|
let url = arguments[0];
|
||||||
let bookmarkIds = PlacesUtils.bookmarks.getBookmarkIdsForURI(makeURI(url), {}, {});
|
PlacesUtils.bookmarks.fetch({url}).then(
|
||||||
return bookmarkIds.length == 1 ? PlacesUtils.bookmarks.getItemTitle(bookmarkIds[0]) : "";
|
bookmark => marionetteScriptFinished(bookmark ? bookmark.title : ""),
|
||||||
|
ex => marionetteScriptFinished(ex)
|
||||||
|
);
|
||||||
""", script_args=(self._bookmarkURL,))
|
""", script_args=(self._bookmarkURL,))
|
||||||
self.assertEqual(titleInBookmarks, self._bookmarkText)
|
self.assertEqual(titleInBookmarks, self._bookmarkText)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user