Bug 775580 - Remove calls to addVisit from test_sorting.js. r=mak

This commit is contained in:
Paolo Amadini 2012-12-08 20:50:59 +01:00
Родитель f4ec69e94d
Коммит ee61295372
2 изменённых файлов: 48 добавлений и 41 удалений

Просмотреть файл

@ -875,7 +875,7 @@ NavHistoryResultObserver.prototype = {
};
/**
* Asynchronously adds visits to a page, invoking a callback function when done.
* Asynchronously adds visits to a page.
*
* @param aPlaceInfo
* Can be an nsIURI, in such a case a single LINK visit will be added.
@ -887,14 +887,14 @@ NavHistoryResultObserver.prototype = {
* [optional] visitDate: visit date in microseconds from the epoch
* [optional] referrer: nsIURI of the referrer for this visit
* }
* @param [optional] aCallback
* Function to be invoked on completion.
* @param [optional] aStack
* The stack frame used to report errors.
*
* @return {Promise}
* @resolves When all visits have been added successfully.
* @rejects JavaScript exception.
*/
function addVisits(aPlaceInfo, aCallback, aStack)
function promiseAddVisits(aPlaceInfo)
{
let stack = aStack || Components.stack.caller;
let deferred = Promise.defer();
let places = [];
if (aPlaceInfo instanceof Ci.nsIURI) {
places.push({ uri: aPlaceInfo });
@ -922,14 +922,34 @@ function addVisits(aPlaceInfo, aCallback, aStack)
PlacesUtils.asyncHistory.updatePlaces(
places,
{
handleError: function AAV_handleError() {
do_throw("Unexpected error in adding visit.", stack);
handleError: function AAV_handleError(aResultCode, aPlaceInfo) {
let ex = new Components.Exception("Unexpected error in adding visits.",
aResultCode);
deferred.reject(ex);
},
handleResult: function () {},
handleCompletion: function UP_handleCompletion() {
if (aCallback)
aCallback();
deferred.resolve();
}
}
);
return deferred.promise;
}
/**
* Asynchronously adds visits to a page, then either invokes a callback function
* on success, or reports a test error on failure.
*
* @deprecated Use promiseAddVisits instead.
*/
function addVisits(aPlaceInfo, aCallback, aStack)
{
let stack = aStack || Components.stack.caller;
promiseAddVisits(aPlaceInfo).then(
aCallback,
function addVisits_onFailure(ex) {
do_throw(ex, stack);
}
);
}

Просмотреть файл

@ -414,22 +414,16 @@ tests.push({
// This function in head_queries.js creates our database with the above data
populateDB(this._unsortedData);
// add visits to increase visit count
PlacesUtils.history.addVisit(uri("http://example.com/a"), timeInMicroseconds, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/b1"), timeInMicroseconds, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/b1"), timeInMicroseconds, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/b2"), timeInMicroseconds + 1, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/b2"), timeInMicroseconds + 1, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/c"), timeInMicroseconds, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/c"), timeInMicroseconds, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
PlacesUtils.history.addVisit(uri("http://example.com/c"), timeInMicroseconds, null,
PlacesUtils.history.TRANSITION_TYPED, false, 0);
yield promiseAddVisits([
{ uri: uri("http://example.com/a"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds },
{ uri: uri("http://example.com/b1"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds },
{ uri: uri("http://example.com/b1"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds },
{ uri: uri("http://example.com/b2"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds + 1 },
{ uri: uri("http://example.com/b2"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds + 1 },
{ uri: uri("http://example.com/c"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds },
{ uri: uri("http://example.com/c"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds },
{ uri: uri("http://example.com/c"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds },
]);
},
check: function() {
@ -1265,23 +1259,16 @@ tests.push({
function run_test() {
do_test_pending();
runNextTest();
}
function runNextTest() {
if (tests.length) {
let test = tests.shift();
test.setup();
promiseAsyncUpdates().then(function () {
Task.spawn(function () {
for (let [, test] in Iterator(tests)) {
yield test.setup();
yield promiseAsyncUpdates();
test.check();
// sorting reversed, usually SORT_BY have ASC and DESC
test.check_reverse();
// Execute cleanup tasks
remove_all_bookmarks();
promiseClearHistory().then(runNextTest);
});
}
else {
do_test_finished();
yield promiseClearHistory();
}
}).then(do_test_finished);
}