Bug 621594 - History sync: failure when title is null. r=mconnor

This commit is contained in:
Philipp von Weitershausen 2010-12-28 17:36:18 -08:00
parent 4cb107444e
commit 0f15591bbb
2 changed files with 20 additions and 2 deletions

View File

@ -427,7 +427,9 @@ HistoryStore.prototype = {
if (curvisits.every(function(cur) cur.date != date))
Svc.History.addVisit(uri, date, null, type, type == 5 || type == 6, 0);
this._hsvc.setPageTitle(uri, record.title);
if (record.title) {
this._hsvc.setPageTitle(uri, record.title);
}
},
itemExists: function HistStore_itemExists(id) {

View File

@ -129,6 +129,22 @@ function run_test() {
visits: [{date: TIMESTAMP3,
type: Ci.nsINavHistoryService.TRANSITION_TYPED}]});
}, function (next) {
_("Make sure we handle a null title gracefully (it can happen in some cases, e.g. for resource:// URLs)");
let resguid = Utils.makeGUID();
let resuri = Utils.makeURI("unknown://title");
store.create({id: resguid,
histUri: resuri.spec,
title: null,
visits: [{date: TIMESTAMP3,
type: Ci.nsINavHistoryService.TRANSITION_TYPED}]});
do_check_eq([id for (id in store.getAllIDs())].length, 3);
let queryres = queryHistoryVisits(resuri);
do_check_eq(queryres.length, 1);
do_check_eq(queryres[0].time, TIMESTAMP3);
next();
}, function (next) {
_("Make sure we handle invalid URLs in places databases gracefully.");
@ -138,7 +154,7 @@ function run_test() {
+ "VALUES ('invalid-uri', 'Invalid URI', '.', 1, " + TIMESTAMP3 + ")";
let stmt = Utils.createStatement(Svc.History.DBConnection, query);
let result = Utils.queryAsync(stmt);
do_check_eq([id for (id in store.getAllIDs())].length, 3);
do_check_eq([id for (id in store.getAllIDs())].length, 4);
_("Remove a record from the store.");
store.remove({id: fxguid});