Import Tycho weave client

This commit is contained in:
wolfbeast 2018-10-06 06:57:51 +02:00 committed by Roy Tam
commit c53787dfdb
183 changed files with 7272 additions and 16759 deletions

View file

@ -68,12 +68,12 @@ function ensureThrows(func) {
};
}
var store = new HistoryEngine(Service)._store;
let store = new HistoryEngine(Service)._store;
function applyEnsureNoFailures(records) {
do_check_eq(store.applyIncomingBatch(records).length, 0);
}
var fxuri, fxguid, tburi, tbguid;
let fxuri, fxguid, tburi, tbguid;
function run_test() {
initTestLogging("Trace");
@ -189,8 +189,8 @@ add_test(function test_invalid_records() {
.DBConnection;
let stmt = connection.createAsyncStatement(
"INSERT INTO moz_places "
+ "(url, url_hash, title, rev_host, visit_count, last_visit_date) "
+ "VALUES ('invalid-uri', hash('invalid-uri'), 'Invalid URI', '.', 1, " + TIMESTAMP3 + ")"
+ "(url, title, rev_host, visit_count, last_visit_date) "
+ "VALUES ('invalid-uri', 'Invalid URI', '.', 1, " + TIMESTAMP3 + ")"
);
Async.querySpinningly(stmt);
stmt.finalize();
@ -198,7 +198,7 @@ add_test(function test_invalid_records() {
stmt = connection.createAsyncStatement(
"INSERT INTO moz_historyvisits "
+ "(place_id, visit_date, visit_type, session) "
+ "VALUES ((SELECT id FROM moz_places WHERE url_hash = hash('invalid-uri') AND url = 'invalid-uri'), "
+ "VALUES ((SELECT id FROM moz_places WHERE url = 'invalid-uri'), "
+ TIMESTAMP3 + ", " + Ci.nsINavHistoryService.TRANSITION_TYPED + ", 1)"
);
Async.querySpinningly(stmt);
@ -226,7 +226,7 @@ add_test(function test_invalid_records() {
type: Ci.nsINavHistoryService.TRANSITION_EMBED}]}
]);
_("Make sure we handle records with invalid visit codes or visit dates, gracefully ignoring those visits.");
_("Make sure we report records with invalid visits, gracefully handle non-integer dates.");
let no_date_visit_guid = Utils.makeGUID();
let no_type_visit_guid = Utils.makeGUID();
let invalid_type_visit_guid = Utils.makeGUID();
@ -235,11 +235,11 @@ add_test(function test_invalid_records() {
{id: no_date_visit_guid,
histUri: "http://no.date.visit/",
title: "Visit has no date",
visits: [{type: Ci.nsINavHistoryService.TRANSITION_EMBED}]},
visits: [{date: TIMESTAMP3}]},
{id: no_type_visit_guid,
histUri: "http://no.type.visit/",
title: "Visit has no type",
visits: [{date: TIMESTAMP3}]},
visits: [{type: Ci.nsINavHistoryService.TRANSITION_EMBED}]},
{id: invalid_type_visit_guid,
histUri: "http://invalid.type.visit/",
title: "Visit has invalid type",
@ -251,7 +251,14 @@ add_test(function test_invalid_records() {
visits: [{date: 1234.567,
type: Ci.nsINavHistoryService.TRANSITION_EMBED}]}
]);
do_check_eq(failed.length, 0);
do_check_eq(failed.length, 3);
failed.sort();
let expected = [no_date_visit_guid,
no_type_visit_guid,
invalid_type_visit_guid].sort();
for (let i = 0; i < expected.length; i++) {
do_check_eq(failed[i], expected[i]);
}
_("Make sure we handle records with javascript: URLs gracefully.");
applyEnsureNoFailures([