mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1288885: Migrate history mochitests to xpcshell. r=aswan
MozReview-Commit-ID: tzQdEJx6TN --HG-- rename : browser/components/extensions/test/browser/browser_ext_history.js => browser/components/extensions/test/xpcshell/test_ext_history.js extra : source : eeb6bc8a42e69e989bb70cc6daf56296936f60b0 extra : histedit_source : cd90f8cfa3040588aa2847d4192bf3ba47edc33b
This commit is contained in:
parent
d8c6a793a6
commit
bd9082edf7
@ -35,7 +35,6 @@ support-files =
|
||||
[browser_ext_contextMenus_urlPatterns.js]
|
||||
[browser_ext_currentWindow.js]
|
||||
[browser_ext_getViews.js]
|
||||
[browser_ext_history.js]
|
||||
[browser_ext_incognito_popup.js]
|
||||
[browser_ext_lastError.js]
|
||||
[browser_ext_optionsPage_privileges.js]
|
||||
|
@ -85,14 +85,14 @@ add_task(function* test_delete() {
|
||||
}
|
||||
|
||||
yield PlacesUtils.history.insertMany(visits);
|
||||
is(yield PlacesTestUtils.visitsInDB(visits[0].url), 5, "5 visits for uri found in history database");
|
||||
equal((yield PlacesTestUtils.visitsInDB(visits[0].url)), 5, "5 visits for uri found in history database");
|
||||
|
||||
let testUrl = visits[2].url;
|
||||
ok(yield PlacesTestUtils.isPageInDB(testUrl), "expected url found in history database");
|
||||
ok((yield PlacesTestUtils.isPageInDB(testUrl)), "expected url found in history database");
|
||||
|
||||
extension.sendMessage("delete-url", testUrl);
|
||||
yield extension.awaitMessage("url-deleted");
|
||||
is(yield PlacesTestUtils.isPageInDB(testUrl), false, "expected url not found in history database");
|
||||
equal((yield PlacesTestUtils.isPageInDB(testUrl)), false, "expected url not found in history database");
|
||||
|
||||
// delete 3 of the 5 visits for url 1
|
||||
let filter = {
|
||||
@ -103,10 +103,10 @@ add_task(function* test_delete() {
|
||||
extension.sendMessage("delete-range", filter);
|
||||
let removedUrls = yield extension.awaitMessage("range-deleted");
|
||||
ok(!removedUrls.includes(visits[0].url), `${visits[0].url} not received by onVisitRemoved`);
|
||||
ok(yield PlacesTestUtils.isPageInDB(visits[0].url), "expected uri found in history database");
|
||||
is(yield PlacesTestUtils.visitsInDB(visits[0].url), 2, "2 visits for uri found in history database");
|
||||
ok(yield PlacesTestUtils.isPageInDB(visits[1].url), "expected uri found in history database");
|
||||
is(yield PlacesTestUtils.visitsInDB(visits[1].url), 1, "1 visit for uri found in history database");
|
||||
ok((yield PlacesTestUtils.isPageInDB(visits[0].url)), "expected uri found in history database");
|
||||
equal((yield PlacesTestUtils.visitsInDB(visits[0].url)), 2, "2 visits for uri found in history database");
|
||||
ok((yield PlacesTestUtils.isPageInDB(visits[1].url)), "expected uri found in history database");
|
||||
equal((yield PlacesTestUtils.visitsInDB(visits[1].url)), 1, "1 visit for uri found in history database");
|
||||
|
||||
// delete the rest of the visits for url 1, and the visit for url 2
|
||||
filter.startTime = visits[0].visits[0].date;
|
||||
@ -115,18 +115,18 @@ add_task(function* test_delete() {
|
||||
extension.sendMessage("delete-range", filter);
|
||||
yield extension.awaitMessage("range-deleted");
|
||||
|
||||
is(yield PlacesTestUtils.isPageInDB(visits[0].url), false, "expected uri not found in history database");
|
||||
is(yield PlacesTestUtils.visitsInDB(visits[0].url), 0, "0 visits for uri found in history database");
|
||||
is(yield PlacesTestUtils.isPageInDB(visits[1].url), false, "expected uri not found in history database");
|
||||
is(yield PlacesTestUtils.visitsInDB(visits[1].url), 0, "0 visits for uri found in history database");
|
||||
equal((yield PlacesTestUtils.isPageInDB(visits[0].url)), false, "expected uri not found in history database");
|
||||
equal((yield PlacesTestUtils.visitsInDB(visits[0].url)), 0, "0 visits for uri found in history database");
|
||||
equal((yield PlacesTestUtils.isPageInDB(visits[1].url)), false, "expected uri not found in history database");
|
||||
equal((yield PlacesTestUtils.visitsInDB(visits[1].url)), 0, "0 visits for uri found in history database");
|
||||
|
||||
ok(yield PlacesTestUtils.isPageInDB(visits[3].url), "expected uri found in history database");
|
||||
ok((yield PlacesTestUtils.isPageInDB(visits[3].url)), "expected uri found in history database");
|
||||
|
||||
extension.sendMessage("delete-all");
|
||||
[historyClearedCount, removedUrls] = yield extension.awaitMessage("history-cleared");
|
||||
is(PlacesUtils.history.hasHistoryEntries, false, "history is empty");
|
||||
is(historyClearedCount, 2, "onVisitRemoved called for each clearing of history");
|
||||
is(removedUrls.length, 3, "onVisitRemoved called the expected number of times");
|
||||
equal(PlacesUtils.history.hasHistoryEntries, false, "history is empty");
|
||||
equal(historyClearedCount, 2, "onVisitRemoved called for each clearing of history");
|
||||
equal(removedUrls.length, 3, "onVisitRemoved called the expected number of times");
|
||||
for (let i = 1; i < 3; ++i) {
|
||||
let url = visits[i].url;
|
||||
ok(removedUrls.includes(url), `${url} received by onVisitRemoved`);
|
||||
@ -215,9 +215,9 @@ add_task(function* test_search() {
|
||||
|
||||
function checkResult(results, url, expectedCount) {
|
||||
let result = findResult(url, results);
|
||||
isnot(result, null, `history.search result was found for ${url}`);
|
||||
is(result.visitCount, expectedCount, `history.search reports ${expectedCount} visit(s)`);
|
||||
is(result.title, `test visit for ${url}`, "title for search result is correct");
|
||||
notEqual(result, null, `history.search result was found for ${url}`);
|
||||
equal(result.visitCount, expectedCount, `history.search reports ${expectedCount} visit(s)`);
|
||||
equal(result.title, `test visit for ${url}`, "title for search result is correct");
|
||||
}
|
||||
|
||||
yield extension.startup();
|
||||
@ -229,21 +229,21 @@ add_task(function* test_search() {
|
||||
extension.sendMessage("check-history");
|
||||
|
||||
let results = yield extension.awaitMessage("empty-search");
|
||||
is(results.length, 3, "history.search with empty text returned 3 results");
|
||||
equal(results.length, 3, "history.search with empty text returned 3 results");
|
||||
checkResult(results, SINGLE_VISIT_URL, 1);
|
||||
checkResult(results, DOUBLE_VISIT_URL, 2);
|
||||
checkResult(results, MOZILLA_VISIT_URL, 1);
|
||||
|
||||
results = yield extension.awaitMessage("text-search");
|
||||
is(results.length, 1, "history.search with specific text returned 1 result");
|
||||
equal(results.length, 1, "history.search with specific text returned 1 result");
|
||||
checkResult(results, MOZILLA_VISIT_URL, 1);
|
||||
|
||||
results = yield extension.awaitMessage("max-results-search");
|
||||
is(results.length, 1, "history.search with maxResults returned 1 result");
|
||||
equal(results.length, 1, "history.search with maxResults returned 1 result");
|
||||
checkResult(results, DOUBLE_VISIT_URL, 2);
|
||||
|
||||
results = yield extension.awaitMessage("date-range-search");
|
||||
is(results.length, 2, "history.search with a date range returned 2 result");
|
||||
equal(results.length, 2, "history.search with a date range returned 2 result");
|
||||
checkResult(results, DOUBLE_VISIT_URL, 2);
|
||||
checkResult(results, SINGLE_VISIT_URL, 1);
|
||||
|
||||
@ -300,11 +300,11 @@ add_task(function* test_add_url() {
|
||||
];
|
||||
|
||||
function* checkUrl(results) {
|
||||
ok(yield PlacesTestUtils.isPageInDB(results.details.url), `${results.details.url} found in history database`);
|
||||
ok((yield PlacesTestUtils.isPageInDB(results.details.url)), `${results.details.url} found in history database`);
|
||||
ok(PlacesUtils.isValidGuid(results.result.id), "URL was added with a valid id");
|
||||
is(results.result.title, results.details.title, "URL was added with the correct title");
|
||||
equal(results.result.title, results.details.title, "URL was added with the correct title");
|
||||
if (results.details.visitTime) {
|
||||
is(results.result.lastVisitTime,
|
||||
equal(results.result.lastVisitTime,
|
||||
Number(ExtensionUtils.normalizeTime(results.details.visitTime)),
|
||||
"URL was added with the correct date");
|
||||
}
|
||||
@ -458,12 +458,12 @@ add_task(function* test_on_visited() {
|
||||
function checkOnVisitedData(index, expected) {
|
||||
let onVisited = onVisitedData[index];
|
||||
ok(PlacesUtils.isValidGuid(onVisited.id), "onVisited received a valid id");
|
||||
is(onVisited.url, expected.url, "onVisited received the expected url");
|
||||
equal(onVisited.url, expected.url, "onVisited received the expected url");
|
||||
// Title will be blank until bug 1287928 lands
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1287928
|
||||
is(onVisited.title, "", "onVisited received a blank title");
|
||||
is(onVisited.lastVisitTime, expected.time, "onVisited received the expected time");
|
||||
is(onVisited.visitCount, expected.visitCount, "onVisited received the expected visitCount");
|
||||
equal(onVisited.title, "", "onVisited received a blank title");
|
||||
equal(onVisited.lastVisitTime, expected.time, "onVisited received the expected time");
|
||||
equal(onVisited.visitCount, expected.visitCount, "onVisited received the expected visitCount");
|
||||
}
|
||||
|
||||
let expected = {
|
@ -4,4 +4,5 @@ tail =
|
||||
firefox-appdir = browser
|
||||
|
||||
[test_ext_bookmarks.js]
|
||||
[test_ext_history.js]
|
||||
[test_ext_manifest_commands.js]
|
||||
|
Loading…
x
Reference in New Issue
Block a user