Bug 1257380 - Fix intermittent test_ext_bookmarks.html. r=kmag

I don't think we can rely on the bookmarks being created in a specific order, although that mostly seems to happen,
so rather than check for an exact list of bookmarks returned from getRecent(), we can just check that the bookmarks
we get back are in reverse chronological order and that the 4 most recently created bookmarks are returned.

MozReview-Commit-ID: DhT7raJRe7N

--HG--
extra : transplant_source : 8%24%A6%3F%87%CD%17M%EC%B0%C4%3A%F3iP%EB%BA%DE%B5%F4
This commit is contained in:
bsilverberg 2016-03-17 11:17:16 +01:00
parent 2049654007
commit 796bd23e28

View File

@ -395,14 +395,21 @@ function backgroundScript() {
createdBookmarks.add(corporationBookmark.id);
});
}).then(() => {
return browser.bookmarks.getRecent(5);
return browser.bookmarks.getRecent(4);
}).then(results => {
browser.test.assertEq(5, results.length, "Expected number of results returned by getRecent");
browser.test.assertEq("About Mozilla", results[0].title, "Bookmark has the expected title");
browser.test.assertEq("Firefox", results[1].title, "Bookmark has the expected title");
browser.test.assertEq("Mozilla Corporation", results[2].title, "Bookmark has the expected title");
browser.test.assertEq("Mozilla", results[3].title, "Bookmark has the expected title");
browser.test.assertEq("Toolbar Item", results[4].title, "Bookmark has the expected title");
browser.test.assertEq(4, results.length, "Expected number of results returned by getRecent");
let prevDate = results[0].dateAdded;
for (let bookmark of results) {
browser.test.assertTrue(bookmark.dateAdded <= prevDate, "The recent bookmarks are sorted by dateAdded");
prevDate = bookmark.dateAdded;
}
let bookmarksByTitle = results.sort((a, b) => {
return a.title.localeCompare(b.title);
});
browser.test.assertEq("About Mozilla", bookmarksByTitle[0].title, "Bookmark has the expected title");
browser.test.assertEq("Firefox", bookmarksByTitle[1].title, "Bookmark has the expected title");
browser.test.assertEq("Mozilla", bookmarksByTitle[2].title, "Bookmark has the expected title");
browser.test.assertEq("Mozilla Corporation", bookmarksByTitle[3].title, "Bookmark has the expected title");
return browser.bookmarks.search({});
}).then(results => {