Backed out changeset 1dac46a1218e
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Thu, 18 Feb 2010 10:00:27 -0800
changeset 38243 ddf7671d13385056207caa2b93f5fe84b7476ad7
parent 38182 1dac46a1218efd1a16fa87b632475fc53f009c80
child 38244 da19fdbc06a5bb5c0ca5b0a3137f76bb1e3ab202
push idunknown
push userunknown
push dateunknown
milestone1.9.3a2pre
backs out1dac46a1218efd1a16fa87b632475fc53f009c80
Backed out changeset 1dac46a1218e
toolkit/components/places/src/History.cpp
toolkit/components/places/tests/cpp/places_test_harness.h
toolkit/components/places/tests/cpp/test_IHistory.cpp
--- a/toolkit/components/places/src/History.cpp
+++ b/toolkit/components/places/src/History.cpp
@@ -46,23 +46,16 @@
 #include "nsIEventStateManager.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 namespace places {
 
 ////////////////////////////////////////////////////////////////////////////////
-//// Global Defines
-
-#define URI_VISITED "visited"
-#define URI_NOT_VISITED "not visited"
-#define URI_VISITED_RESOLUTION_TOPIC "visited-status-resolution"
-
-////////////////////////////////////////////////////////////////////////////////
 //// Anonymous Helpers
 
 namespace {
 
 class VisitedQuery : public mozIStorageStatementCallback
 {
 public:
   NS_DECL_ISUPPORTS
@@ -107,34 +100,16 @@ public:
     return NS_OK;
   }
 
   NS_IMETHOD HandleCompletion(PRUint16 aReason)
   {
     if (mIsVisited) {
       History::GetService()->NotifyVisited(mURI);
     }
-
-    // Notify any observers about that we have resolved the visited state of
-    // this URI.
-    nsCOMPtr<nsIObserverService> observerService =
-      do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
-    if (observerService) {
-      nsAutoString status;
-      if (mIsVisited) {
-        status.AssignLiteral(URI_VISITED);
-      }
-      else {
-        status.AssignLiteral(URI_NOT_VISITED);
-      }
-      (void)observerService->NotifyObservers(mURI,
-                                             URI_VISITED_RESOLUTION_TOPIC,
-                                             status.get());
-    }
-
     return NS_OK;
   }
 private:
   VisitedQuery(nsIURI* aURI)
   : mURI(aURI)
   , mIsVisited(false)
   {
   }
--- a/toolkit/components/places/tests/cpp/places_test_harness.h
+++ b/toolkit/components/places/tests/cpp/places_test_harness.h
@@ -71,19 +71,16 @@ static size_t gPassedTests = 0;
     } else { \
       fail("Expected false, got true at %s:%d!", __FILE__, __LINE__); \
     } \
   PR_END_MACRO
 
 #define do_check_success(aResult) \
   do_check_true(NS_SUCCEEDED(aResult))
 
-#define do_check_eq(aFirst, aSecond) \
-  do_check_true(aFirst == aSecond)
-
 struct Test
 {
   void (*func)(void);
   const char* const name;
 };
 #define TEST(aName) \
   {aName, #aName}
 
--- a/toolkit/components/places/tests/cpp/test_IHistory.cpp
+++ b/toolkit/components/places/tests/cpp/test_IHistory.cpp
@@ -243,144 +243,28 @@ test_RegisterVisitedCallback_returns_bef
   // Remove ourselves as an observer.  We would have failed if we had been
   // notified.
   rv = history->UnregisterVisitedCallback(testURI, link);
   do_check_success(rv);
 
   run_next_test();
 }
 
-namespace test_observer_topic_dispatched_helpers {
-  #define URI_VISITED "visited"
-  #define URI_NOT_VISITED "not visited"
-  #define URI_VISITED_RESOLUTION_TOPIC "visited-status-resolution"
-  class statusObserver : public nsIObserver
-  {
-  public:
-    NS_DECL_ISUPPORTS
-
-    statusObserver(nsIURI* aURI,
-                   const bool aExpectVisit,
-                   bool& _notified)
-    : mURI(aURI)
-    , mExpectVisit(aExpectVisit)
-    , mNotified(_notified)
-    {
-      nsCOMPtr<nsIObserverService> observerService =
-        do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
-      do_check_true(observerService);
-      (void)observerService->AddObserver(this,
-                                         URI_VISITED_RESOLUTION_TOPIC,
-                                         PR_FALSE);
-    }
-
-    NS_IMETHOD Observe(nsISupports* aSubject,
-                       const char* aTopic,
-                       const PRUnichar* aData)
-    {
-      // Make sure we got notified of the right topic.
-      do_check_false(strcmp(aTopic, URI_VISITED_RESOLUTION_TOPIC));
-
-      // If this isn't for our URI, do not do anything.
-      nsCOMPtr<nsIURI> notifiedURI(do_QueryInterface(aSubject));
-      do_check_true(notifiedURI);
-      PRBool isOurURI;
-      nsresult rv = notifiedURI->Equals(mURI, &isOurURI);
-      do_check_success(rv);
-      if (!isOurURI) {
-        return NS_OK;
-      }
-
-      // Check that we have either the visited or not visited string.
-      bool visited = !!NS_LITERAL_STRING(URI_VISITED).Equals(aData);
-      bool notVisited = !!NS_LITERAL_STRING(URI_NOT_VISITED).Equals(aData);
-      do_check_true(visited || notVisited);
-
-      // Check to make sure we got the state we expected.
-      do_check_eq(mExpectVisit, visited);
-
-      // Indicate that we've been notified.
-      mNotified = true;
-
-      // Remove ourselves as an observer.
-      nsCOMPtr<nsIObserverService> observerService =
-        do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
-      (void)observerService->RemoveObserver(this,
-                                            URI_VISITED_RESOLUTION_TOPIC);
-      return NS_OK;
-    }
-  private:
-    nsCOMPtr<nsIURI> mURI;
-    const bool mExpectVisit;
-    bool& mNotified;
-  };
-  NS_IMPL_ISUPPORTS1(
-    statusObserver,
-    nsIObserver
-  )
-}
-void
-test_observer_topic_dispatched()
-{
-  using namespace test_observer_topic_dispatched_helpers;
-
-  // Create two URIs, making sure only one is in history.
-  nsCOMPtr<nsIURI> visitedURI(new_test_uri());
-  nsCOMPtr<nsIURI> notVisitedURI(new_test_uri());
-  PRBool urisEqual;
-  nsresult rv = visitedURI->Equals(notVisitedURI, &urisEqual);
-  do_check_success(rv);
-  do_check_false(urisEqual);
-  addURI(visitedURI);
-
-  // Need two Link objects as well - one for each URI.
-  nsCOMPtr<Link> visitedLink(new mock_Link(expect_visit, false));
-  NS_ADDREF(visitedLink); // It will release itself when notified.
-  nsCOMPtr<Link> notVisitedLink(new mock_Link(expect_no_visit));
-
-  // Add the right observers for the URIs to check results.
-  bool visitedNotified = false;
-  nsCOMPtr<nsIObserver> vistedObs =
-    new statusObserver(visitedURI, true, visitedNotified);
-  bool notVisitedNotified = false;
-  nsCOMPtr<nsIObserver> unvistedObs =
-    new statusObserver(notVisitedURI, false, notVisitedNotified);
-
-  // Register our Links to be notified.
-  nsCOMPtr<IHistory> history(do_get_IHistory());
-  rv = history->RegisterVisitedCallback(visitedURI, visitedLink);
-  do_check_success(rv);
-  rv = history->RegisterVisitedCallback(notVisitedURI, notVisitedLink);
-  do_check_success(rv);
-
-  // Spin the event loop as long as we have not been properly notified.
-  while (!visitedNotified || !notVisitedNotified) {
-    (void)NS_ProcessNextEvent();
-  }
-
-  // Unregister our observer that would not have been released.
-  rv = history->UnregisterVisitedCallback(notVisitedURI, notVisitedLink);
-  do_check_success(rv);
-
-  run_next_test();
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 //// Test Harness
 
 /**
  * Note: for tests marked "Order Important!", please see the test for details.
  */
 Test gTests[] = {
   TEST(test_unvisted_does_not_notify_part1), // Order Important!
   TEST(test_visited_notifies),
   TEST(test_unvisted_does_not_notify_part2), // Order Important!
   TEST(test_same_uri_notifies_both),
   TEST(test_unregistered_visited_does_not_notify), // Order Important!
   TEST(test_new_visit_notifies_waiting_Link),
   TEST(test_RegisterVisitedCallback_returns_before_notifying),
-  TEST(test_observer_topic_dispatched),
 };
 
 const char* file = __FILE__;
 #define TEST_NAME "IHistory"
 #define TEST_FILE file
 #include "places_test_harness_tail.h"