diff --git a/accessible/src/base/nsAccDocManager.cpp b/accessible/src/base/nsAccDocManager.cpp index f36473f10f7..0620e5d6b7e 100644 --- a/accessible/src/base/nsAccDocManager.cpp +++ b/accessible/src/base/nsAccDocManager.cpp @@ -214,6 +214,10 @@ nsAccDocManager::OnStateChange(nsIWebProgress *aWebProgress, nsEventShell::FireEvent(reloadEvent); } + // Mark the document accessible as loading, if it stays alive then we'll mark + // it as loaded when we receive proper notification. + docAcc->MarkAsLoading(); + // Fire state busy change event. Use delayed event since we don't care // actually if event isn't delivered when the document goes away like a shot. nsRefPtr stateEvent = @@ -310,8 +314,7 @@ nsAccDocManager::HandleEvent(nsIDOMEvent *aEvent) nsCoreUtils::IsErrorPage(document)) { NS_LOG_ACCDOCLOAD2("handled 'DOMContentLoaded' event", document) HandleDOMDocumentLoad(document, - nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE, - PR_TRUE); + nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE); } return NS_OK; @@ -322,8 +325,7 @@ nsAccDocManager::HandleEvent(nsIDOMEvent *aEvent) void nsAccDocManager::HandleDOMDocumentLoad(nsIDocument *aDocument, - PRUint32 aLoadEventType, - PRBool aMarkAsLoaded) + PRUint32 aLoadEventType) { // Document accessible can be created before we were notified the DOM document // was loaded completely. However if it's not created yet then create it. @@ -335,8 +337,8 @@ nsAccDocManager::HandleDOMDocumentLoad(nsIDocument *aDocument, return; } - if (aMarkAsLoaded) - docAcc->MarkAsLoaded(); + // Mark the document as loaded to drop off the busy state flag on it. + docAcc->MarkAsLoaded(); // Do not fire document complete/stop events for root chrome document // accessibles and for frame/iframe documents because diff --git a/accessible/src/base/nsAccDocManager.h b/accessible/src/base/nsAccDocManager.h index 2f9b097950c..e97bf4ef7ae 100644 --- a/accessible/src/base/nsAccDocManager.h +++ b/accessible/src/base/nsAccDocManager.h @@ -116,13 +116,9 @@ private: * @param aDocument [in] loaded DOM document * @param aLoadEventType [in] specifies the event type to fire load event, * if 0 then no event is fired - * @param aMarkAsLoaded [in] indicates whether we should mark forcedly - * an accessible document as loaded (used for error - * pages only which do not get 'pageshow' event) */ void HandleDOMDocumentLoad(nsIDocument *aDocument, - PRUint32 aLoadEventType, - PRBool aMarkAsLoaded = PR_FALSE); + PRUint32 aLoadEventType); /** * Return true if accessibility events accompanying document accessible diff --git a/accessible/src/base/nsCoreUtils.cpp b/accessible/src/base/nsCoreUtils.cpp index b6116894dda..796ec42c046 100644 --- a/accessible/src/base/nsCoreUtils.cpp +++ b/accessible/src/base/nsCoreUtils.cpp @@ -460,19 +460,6 @@ nsCoreUtils::GetDocShellTreeItemFor(nsINode *aNode) return docShellTreeItem; } -PRBool -nsCoreUtils::IsDocumentBusy(nsIDocument *aDocument) -{ - nsCOMPtr container = aDocument->GetContainer(); - nsCOMPtr docShell = do_QueryInterface(container); - if (!docShell) - return PR_TRUE; - - PRUint32 busyFlags = 0; - docShell->GetBusyFlags(&busyFlags); - return (busyFlags != nsIDocShell::BUSY_FLAGS_NONE); -} - PRBool nsCoreUtils::IsRootDocument(nsIDocument *aDocument) { diff --git a/accessible/src/base/nsCoreUtils.h b/accessible/src/base/nsCoreUtils.h index f09058fac23..ef895301dec 100644 --- a/accessible/src/base/nsCoreUtils.h +++ b/accessible/src/base/nsCoreUtils.h @@ -223,11 +223,6 @@ public: static already_AddRefed GetDocShellTreeItemFor(nsINode *aNode); - /** - * Return true if document is loading. - */ - static PRBool IsDocumentBusy(nsIDocument *aDocument); - /** * Return true if the given document is root document. */ diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 903c3f15004..54573538d90 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -319,7 +319,7 @@ nsDocAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) *aState |= nsIAccessibleStates::STATE_FOCUSED; } - if (nsCoreUtils::IsDocumentBusy(mDocument)) { + if (!mIsLoaded) { *aState |= nsIAccessibleStates::STATE_BUSY; if (aExtraState) { *aExtraState |= nsIAccessibleStates::EXT_STATE_STALE; diff --git a/accessible/src/base/nsDocAccessible.h b/accessible/src/base/nsDocAccessible.h index 488b38a24d6..cb1c3c0f6f6 100644 --- a/accessible/src/base/nsDocAccessible.h +++ b/accessible/src/base/nsDocAccessible.h @@ -138,11 +138,14 @@ public: } /** - * Marks as loaded, used for error pages as workaround since they do not + * Marks this document as loaded or loading, used to expose busy state. + * The loaded flag has special meaning for error pages and used as workaround + * to make IsContentLoaded() return correct result since these pages do not * receive pageshow event and as consequence nsIDocument::IsShowing() returns * false. */ void MarkAsLoaded() { mIsLoaded = PR_TRUE; } + void MarkAsLoading() { mIsLoaded = PR_FALSE; } /** * Return a native window handler or pointer depending on platform. diff --git a/accessible/tests/mochitest/events/docload_wnd.xul b/accessible/tests/mochitest/events/docload_wnd.xul index a768d970aea..035f3fa56ed 100644 --- a/accessible/tests/mochitest/events/docload_wnd.xul +++ b/accessible/tests/mochitest/events/docload_wnd.xul @@ -28,6 +28,13 @@ gOpenerWnd.SimpleTest.is(aExpected, aActual, aMsg); } + function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState, + aAbsentExtraState) + { + gOpenerWnd.testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState, + aAbsentExtraState); + } + var invokerChecker = gOpenerWnd.invokerChecker; const STATE_BUSY = gOpenerWnd.STATE_BUSY; @@ -91,6 +98,9 @@ is(event.state, STATE_BUSY, "Wrong state of statechange event."); is(event.isEnabled(), aIsEnabled, "Wrong value of state of statechange event"); + + testStates(event.accessible, (aIsEnabled ? STATE_BUSY : 0), 0, + (aIsEnabled ? 0 : STATE_BUSY), 0); } } diff --git a/accessible/tests/mochitest/events/test_docload.xul b/accessible/tests/mochitest/events/test_docload.xul index 39a4f142685..f86a696ee49 100644 --- a/accessible/tests/mochitest/events/test_docload.xul +++ b/accessible/tests/mochitest/events/test_docload.xul @@ -17,6 +17,8 @@ src="../common.js"> +