Bug 504837: Hashchange event should not be restricted to firing only when the document's readystate is 'complete'. r/sr=smaug
☠☠ backed out by a7af1507a5a9 ☠ ☠
authorJustin Lebar <jlebar@mozilla.com>
Mon, 20 Jul 2009 14:09:04 -0700
changeset 30475 a28347623d0f7332186df1c5a84b016864fb66ba
parent 30474 a568cdcd510d572e9035b554c7d028de5503d7a8
child 30476 a7af1507a5a909b1b3090cb63047325899f3a151
push id8102
push userjst@mozilla.com
push dateMon, 20 Jul 2009 23:17:10 +0000
treeherdermozilla-central@a28347623d0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs504837
milestone1.9.2a1pre
Bug 504837: Hashchange event should not be restricted to firing only when the document's readystate is 'complete'. r/sr=smaug
docshell/test/test_bug385434.html
dom/base/nsGlobalWindow.cpp
--- a/docshell/test/test_bug385434.html
+++ b/docshell/test/test_bug385434.html
@@ -184,29 +184,23 @@ function run_test() {
      "Event type should be 'hashchange'.");
   is(gSampleEvent.cancelable, false,
      "The hashchange event shouldn't be cancelable.");
   is(gSampleEvent.bubbles, false,
      "The hashchange event shouldn't bubble.");
 
   /*
    * TEST 3 tests that:
-   *     hashchange is not dispatched if the current document readyState is
-   *     not "complete".
+   *     hashchange is dispatched if the current document readyState is
+   *     not "complete" (bug 504837).
    */
-  enableIframeLoadCallback();
   frameCw.document.location = "file_bug385434_3.html";
   yield;
-  noEventExpected("Hashchange shouldn't fire if the document " +
-                  "hasn't finished loading.");
-
-  longWait();
-  yield;
-  noEventExpected("Hashchange shouldn't fire after longWait() if " +
-                  "the document hasn't finished loading.");
+  eventExpected("Hashchange should fire even if the document " +
+                "hasn't finished loading.");
 
   /*
    * TEST 4 tests that if we
    *
    *    * Load a page A
    *    * Register a hashchange callback on A
    *    * Navigate to A#foo
    *    * Redirect to a different page, B, before the hashchange event triggered
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -6764,22 +6764,16 @@ nsGlobalWindow::PageHidden()
   mNeedsFocus = PR_TRUE;
 }
 
 nsresult
 nsGlobalWindow::DispatchAsyncHashchange()
 {
   FORWARD_TO_INNER(DispatchAsyncHashchange, (), NS_OK);
 
-  nsIDocument::ReadyState readyState = mDoc->GetReadyStateEnum();
-
-  // We only queue up the event if the ready state is currently "complete"
-  if (readyState != nsIDocument::READYSTATE_COMPLETE)
-      return NS_OK;
-
   nsCOMPtr<nsIRunnable> event =
     NS_NEW_RUNNABLE_METHOD(nsGlobalWindow, this, FireHashchange);
    
   return NS_DispatchToCurrentThread(event);
 }
 
 nsresult
 nsGlobalWindow::FireHashchange()