author | Philipp von Weitershausen <philipp@weitershausen.de> |
Fri, 19 Aug 2011 10:11:37 -0700 | |
changeset 75770 | ba8de1dee071c2cb926f7b618910b1b6ba16d58b |
parent 75769 | 361251a52012e8623c12468870a992996aa37b38 |
child 75771 | d8fa1eccdbbe852a45414db3ba9a982abe9ce67f |
push id | 1441 |
push user | pweitershausen@mozilla.com |
push date | Wed, 24 Aug 2011 01:33:19 +0000 |
treeherder | mozilla-inbound@7857bbf3a523 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mak |
bugs | 676110 |
milestone | 9.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
toolkit/components/places/tests/unit/test_async_history_api.js | file | annotate | diff | comparison | revisions |
--- a/toolkit/components/places/tests/unit/test_async_history_api.js +++ b/toolkit/components/places/tests/unit/test_async_history_api.js @@ -12,17 +12,16 @@ XPCOMUtils.defineLazyServiceGetter(this, "@mozilla.org/browser/history;1", "mozIAsyncHistory"); XPCOMUtils.defineLazyServiceGetter(this, "gGlobalHistory", "@mozilla.org/browser/nav-history-service;1", "nsIGlobalHistory2"); const TEST_DOMAIN = "http://mozilla.org/"; -const TOPIC_UPDATEPLACES_COMPLETE = "places-updatePlaces-complete"; const URI_VISIT_SAVED = "uri-visit-saved"; const RECENT_EVENT_THRESHOLD = 15 * 60 * 1000000; //////////////////////////////////////////////////////////////////////////////// //// Helpers /** * Object that represents a mozIVisitInfo object. @@ -737,24 +736,24 @@ function test_place_id_ignored() }, handleError: function handleError(aResultCode) { do_throw("Unexpected error: " + aResultCode); } }); })); } -function test_observer_topic_dispatched_when_complete() +function test_handleCompletion_called_when_complete() { // We test a normal visit, and embeded visit, and a uri that would fail // the canAddURI test to make sure that the notification happens after *all* // of them have had a callback. let places = [ { uri: NetUtil.newURI(TEST_DOMAIN + - "test_observer_topic_dispatched_when_complete"), + "test_handleCompletion_called_when_complete"), visits: [ new VisitInfo(), new VisitInfo(TRANSITION_EMBED), ], }, { uri: NetUtil.newURI("data:,Hello%2C%20World!"), visits: [ new VisitInfo(), @@ -772,30 +771,23 @@ function test_observer_topic_dispatched_ gHistory.updatePlaces(places, { handleResult: function handleResult(aPlaceInfo) { let checker = PlacesUtils.history.canAddURI(aPlaceInfo.uri) ? do_check_true : do_check_false; callbackCountSuccess++; }, handleError: function handleError(aResultCode, aPlaceInfo) { callbackCountFailure++; - } - }); - - let observer = { - observe: function(aSubject, aTopic, aData) - { - do_check_eq(aTopic, TOPIC_UPDATEPLACES_COMPLETE); + }, + handleCompletion: function handleCompletion() { do_check_eq(callbackCountSuccess, EXPECTED_COUNT_SUCCESS); do_check_eq(callbackCountFailure, EXPECTED_COUNT_FAILURE); - Services.obs.removeObserver(observer, TOPIC_UPDATEPLACES_COMPLETE); waitForAsyncUpdates(run_next_test); }, - }; - Services.obs.addObserver(observer, TOPIC_UPDATEPLACES_COMPLETE, false); + }); } function test_add_visit() { const VISIT_TIME = Date.now() * 1000; let place = { uri: NetUtil.newURI(TEST_DOMAIN + "test_add_visit"), title: "test_add_visit title", @@ -1295,25 +1287,18 @@ function test_callbacks_not_supplied() catch (e if e.result === Cr.NS_ERROR_FAILURE) { // NetUtil.newURI() can throw if e.g. our app knows about imap:// // but the account is not set up and so the URL is invalid for us. // Note this in the log but ignore as it's not the subject of this test. do_log_info("Could not construct URI for '" + url + "'; ignoring"); } }); - gHistory.updatePlaces(places, {} ); - let observer = { - observe: function(aSubject, aTopic, aData) - { - Services.obs.removeObserver(observer, TOPIC_UPDATEPLACES_COMPLETE); - waitForAsyncUpdates(run_next_test); - }, - }; - Services.obs.addObserver(observer, TOPIC_UPDATEPLACES_COMPLETE, false); + gHistory.updatePlaces(places, {}); + waitForAsyncUpdates(run_next_test); } //////////////////////////////////////////////////////////////////////////////// //// Test Runner [ test_interface_exists, test_invalid_uri_throws, @@ -1328,17 +1313,17 @@ function test_callbacks_not_supplied() test_non_addable_uri_errors, test_duplicate_guid_errors, test_invalid_referrerURI_ignored, test_nonnsIURI_referrerURI_ignored, test_invalid_sessionId_ignored, test_unstored_sessionId_ignored, test_old_referrer_ignored, test_place_id_ignored, - test_observer_topic_dispatched_when_complete, + test_handleCompletion_called_when_complete, test_add_visit, test_properties_saved, test_guid_saved, test_referrer_saved, test_sessionId_saved, test_guid_change_saved, test_title_change_saved, test_no_title_does_not_clear_title,