mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Backed out changeset eb94759f0fcf (bug 1356567) for test failures in own test
This commit is contained in:
parent
bb8678e3b4
commit
16969b40e2
@ -34,11 +34,11 @@ function run_test() {
|
||||
// url prefix for test history population
|
||||
const TEST_URL = "https://mozilla.com/";
|
||||
// time when the test starts execution
|
||||
const TIME_NOW = new Date();
|
||||
const TIME_NOW = (new Date()).getTime();
|
||||
|
||||
// utility function to compute past timestap
|
||||
function timeDaysAgo(numDays) {
|
||||
return new Date(TIME_NOW - (numDays * 24 * 60 * 60 * 1000));
|
||||
return TIME_NOW - (numDays * 24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
// utility function to make a visit for insetion into places db
|
||||
|
@ -363,7 +363,7 @@ HistoryStore.prototype = {
|
||||
for (i = 0, k = 0; i < record.visits.length; i++) {
|
||||
let visit = record.visits[k] = record.visits[i];
|
||||
|
||||
if (!visit.date || typeof visit.date != "number" || !Number.isInteger(visit.date)) {
|
||||
if (!visit.date || typeof visit.date != "number") {
|
||||
this._log.warn("Encountered record with invalid visit date: "
|
||||
+ visit.date);
|
||||
continue;
|
||||
|
@ -2,7 +2,6 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Cu.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Cu.import("resource://testing-common/PlacesTestUtils.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://services-common/async.js");
|
||||
Cu.import("resource://services-sync/engines/history.js");
|
||||
@ -89,9 +88,23 @@ add_test(function test_store() {
|
||||
_("Let's create an entry in the database.");
|
||||
fxuri = Utils.makeURI("http://getfirefox.com/");
|
||||
|
||||
PlacesTestUtils.addVisits({ uri: fxuri, title: "Get Firefox!",
|
||||
visitDate: TIMESTAMP1 })
|
||||
.then(() => {
|
||||
let place = {
|
||||
uri: fxuri,
|
||||
title: "Get Firefox!",
|
||||
visits: [{
|
||||
visitDate: TIMESTAMP1,
|
||||
transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
|
||||
}]
|
||||
};
|
||||
PlacesUtils.asyncHistory.updatePlaces(place, {
|
||||
handleError: function handleError() {
|
||||
do_throw("Unexpected error in adding visit.");
|
||||
},
|
||||
handleResult: function handleResult() {},
|
||||
handleCompletion: onVisitAdded
|
||||
});
|
||||
|
||||
function onVisitAdded() {
|
||||
_("Verify that the entry exists.");
|
||||
let ids = Object.keys(store.getAllIDs());
|
||||
do_check_eq(ids.length, 1);
|
||||
@ -128,7 +141,7 @@ add_test(function test_store() {
|
||||
title: "Hol Dir Firefox!",
|
||||
visits: [record.visits[0], secondvisit]}
|
||||
]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
add_test(function test_store_create() {
|
||||
|
@ -69,7 +69,7 @@ FetchPageInfo(const RefPtr<Database>& aDB,
|
||||
"AND EXISTS(SELECT 1 FROM moz_bookmarks b WHERE b.fk = r_place_id) "
|
||||
"LIMIT 1 "
|
||||
") "
|
||||
"), fixup_url(get_unreversed_host(h.rev_host)) AS host "
|
||||
") "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_pages_w_icons pi ON page_url_hash = hash(:page_url) AND page_url = :page_url "
|
||||
"WHERE h.url_hash = hash(:page_url) AND h.url = :page_url",
|
||||
@ -111,11 +111,6 @@ FetchPageInfo(const RefPtr<Database>& aDB,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (_page.host.IsEmpty()) {
|
||||
rv = stmt->GetUTF8String(4, _page.host);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!_page.canAddToHistory) {
|
||||
// Either history is disabled or the scheme is not supported. In such a
|
||||
// case we want to update the icon only if the page is bookmarked.
|
||||
@ -841,9 +836,7 @@ AsyncAssociateIconToPage::Run()
|
||||
// Don't associate pages to root domain icons, since those will be returned
|
||||
// regardless. This saves a lot of work and database space since we don't
|
||||
// need to store urls and relations.
|
||||
// Though, this is possible only if both the page and the icon have the same
|
||||
// host, otherwise we couldn't relate them.
|
||||
if (!mIcon.rootIcon || !mIcon.host.Equals(mPage.host)) {
|
||||
if (!mIcon.rootIcon) {
|
||||
// The page may have associated payloads already, and those could have to be
|
||||
// expired. For example at a certain point a page could decide to stop serving
|
||||
// its usual 16px and 32px pngs, and use an svg instead.
|
||||
|
@ -92,7 +92,6 @@ struct IconData
|
||||
}
|
||||
|
||||
nsCString spec;
|
||||
nsCString host;
|
||||
PRTime expiration;
|
||||
enum AsyncFaviconFetchMode fetchMode;
|
||||
uint16_t status; // This is a bitset, see ICON_STATUS_* defines above.
|
||||
@ -116,8 +115,8 @@ struct PageData
|
||||
int64_t id; // This is the moz_pages_w_icons id.
|
||||
int64_t placeId; // This is the moz_places page id.
|
||||
nsCString spec;
|
||||
nsCString host;
|
||||
nsCString bookmarkedSpec;
|
||||
nsString revHost;
|
||||
bool canAddToHistory; // False for disabled history and unsupported schemas.
|
||||
nsCString guid;
|
||||
};
|
||||
|
@ -2977,19 +2977,6 @@ History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos,
|
||||
// We must have a date and a transaction type!
|
||||
rv = GetIntFromJSObject(aCtx, visit, "visitDate", &data.visitTime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// visitDate should be in microseconds. It's easy to do the wrong thing
|
||||
// and pass milliseconds to updatePlaces, so we lazily check for that.
|
||||
// While it's not easily distinguishable, since both are integers, we can
|
||||
// check if the value is very far in the past, and assume it's probably
|
||||
// a mistake.
|
||||
if (data.visitTime < (PR_Now() / 1000)) {
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
|
||||
Unused << xpc->DebugDumpJSStack(false, false, false);
|
||||
MOZ_CRASH("invalid time format passed to updatePlaces");
|
||||
#endif
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
uint32_t transitionType = 0;
|
||||
rv = GetIntFromJSObject(aCtx, visit, "transitionType", &transitionType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -339,11 +339,8 @@ nsFaviconService::SetAndFetchFaviconForPage(nsIURI* aPageURI,
|
||||
PageData page;
|
||||
rv = aPageURI->GetSpec(page.spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// URIs can arguably lack a host.
|
||||
Unused << aPageURI->GetHost(page.host);
|
||||
if (StringBeginsWith(page.host, NS_LITERAL_CSTRING("www."))) {
|
||||
page.host.Cut(0, 4);
|
||||
}
|
||||
// URIs can arguably miss a host.
|
||||
Unused << GetReversedHostname(aPageURI, page.revHost);
|
||||
bool canAddToHistory;
|
||||
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
|
||||
NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -362,11 +359,6 @@ nsFaviconService::SetAndFetchFaviconForPage(nsIURI* aPageURI,
|
||||
icon.fetchMode = aForceReload ? FETCH_ALWAYS : FETCH_IF_MISSING;
|
||||
rv = aFaviconURI->GetSpec(icon.spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// URIs can arguably lack a host.
|
||||
Unused << aFaviconURI->GetHost(icon.host);
|
||||
if (StringBeginsWith(icon.host, NS_LITERAL_CSTRING("www."))) {
|
||||
icon.host.Cut(0, 4);
|
||||
}
|
||||
nsAutoCString path;
|
||||
rv = aFaviconURI->GetPath(path);
|
||||
if (NS_SUCCEEDED(rv) && path.EqualsLiteral("/favicon.ico")) {
|
||||
@ -445,11 +437,6 @@ nsFaviconService::ReplaceFaviconData(nsIURI* aFaviconURI,
|
||||
if (NS_SUCCEEDED(rv) && path.EqualsLiteral("/favicon.ico")) {
|
||||
iconData->rootIcon = 1;
|
||||
}
|
||||
// URIs can arguably lack a host.
|
||||
Unused << aFaviconURI->GetHost(iconData->host);
|
||||
if (StringBeginsWith(iconData->host, NS_LITERAL_CSTRING("www."))) {
|
||||
iconData->host.Cut(0, 4);
|
||||
}
|
||||
|
||||
IconPayload payload;
|
||||
payload.mimeType = aMimeType;
|
||||
|
@ -63,15 +63,7 @@ this.PlacesTestUtils = Object.freeze({
|
||||
}
|
||||
let visitDate = place.visitDate;
|
||||
if (visitDate) {
|
||||
if (visitDate.constructor.name != "Date") {
|
||||
// visitDate should be in microseconds. It's easy to do the wrong thing
|
||||
// and pass milliseconds to updatePlaces, so we lazily check for that.
|
||||
// While it's not easily distinguishable, since both are integers, we
|
||||
// can check if the value is very far in the past, and assume it's
|
||||
// probably a mistake.
|
||||
if (visitDate <= Date.now()) {
|
||||
throw new Error("AddVisits expects a Date object or _micro_seconds!");
|
||||
}
|
||||
if (!(visitDate instanceof Date)) {
|
||||
visitDate = PlacesUtils.toDate(visitDate);
|
||||
}
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ add_task(function* test_removePagesByTimeframe() {
|
||||
// Add a visit in the past with no directly associated icon.
|
||||
yield PlacesTestUtils.addVisits({uri: "http://www.places.test/old/", visitDate: new Date(Date.now() - 86400000)});
|
||||
let pageURI = NetUtil.newURI("http://www.places.test/page/");
|
||||
yield PlacesTestUtils.addVisits({uri: pageURI, visitDate: new Date(Date.now() - 7200000)});
|
||||
yield PlacesTestUtils.addVisits(pageURI);
|
||||
let faviconURI = NetUtil.newURI("http://www.places.test/page/favicon.ico");
|
||||
let rootIconURI = NetUtil.newURI("http://www.places.test/favicon.ico");
|
||||
PlacesUtils.favicons.replaceFaviconDataFromDataURL(
|
||||
@ -65,7 +65,7 @@ add_task(function* test_removePagesByTimeframe() {
|
||||
rootIconURI.spec, "Should get the root icon");
|
||||
|
||||
PlacesUtils.history.removePagesByTimeframe(
|
||||
PlacesUtils.toPRTime(Date.now() - 14400000),
|
||||
PlacesUtils.toPRTime(Date.now() - 20000),
|
||||
PlacesUtils.toPRTime(new Date())
|
||||
);
|
||||
|
||||
@ -83,15 +83,3 @@ add_task(function* test_removePagesByTimeframe() {
|
||||
rows = yield db.execute("SELECT * FROM moz_icons");
|
||||
Assert.equal(rows.length, 0, "There should be no icon entry");
|
||||
});
|
||||
|
||||
add_task(function* test_different_host() {
|
||||
let pageURI = NetUtil.newURI("http://places.test/page/");
|
||||
yield PlacesTestUtils.addVisits(pageURI);
|
||||
let faviconURI = NetUtil.newURI("http://mozilla.test/favicon.ico");
|
||||
PlacesUtils.favicons.replaceFaviconDataFromDataURL(
|
||||
faviconURI, SMALLPNG_DATA_URI.spec, 0, Services.scriptSecurityManager.getSystemPrincipal());
|
||||
yield setFaviconForPage(pageURI, faviconURI);
|
||||
|
||||
Assert.equal(yield getFaviconUrlForPage(pageURI),
|
||||
faviconURI.spec, "Should get the png icon");
|
||||
});
|
||||
|
@ -26,6 +26,10 @@ var pages = [
|
||||
"http://b.mozilla.org/8/",
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function* test_initialize() {
|
||||
var noon = new Date();
|
||||
noon.setHours(12);
|
||||
@ -35,7 +39,7 @@ add_task(function* test_initialize() {
|
||||
let page = pages[pageIndex];
|
||||
yield PlacesTestUtils.addVisits({
|
||||
uri: uri(page),
|
||||
visitDate: new Date(noon - (pages.length - pageIndex))
|
||||
visitDate: noon - (pages.length - pageIndex) * 1000
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user