diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp index e8d3c59f0691..49ab420022cc 100644 --- a/accessible/src/base/nsAccessNode.cpp +++ b/accessible/src/base/nsAccessNode.cpp @@ -40,7 +40,7 @@ #include "nsIAccessible.h" #include "nsAccessibilityAtoms.h" #include "nsHashtable.h" -#include "nsIAccessibilityService.h" +#include "nsAccessibilityService.h" #include "nsIAccessibleDocument.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" @@ -82,27 +82,19 @@ nsIStringBundle *nsAccessNode::gStringBundle = 0; nsIStringBundle *nsAccessNode::gKeyStringBundle = 0; nsITimer *nsAccessNode::gDoCommandTimer = 0; nsIDOMNode *nsAccessNode::gLastFocusedNode = 0; +#ifdef DEBUG PRBool nsAccessNode::gIsAccessibilityActive = PR_FALSE; -PRBool nsAccessNode::gIsShuttingDownApp = PR_FALSE; +#endif PRBool nsAccessNode::gIsCacheDisabled = PR_FALSE; PRBool nsAccessNode::gIsFormFillEnabled = PR_FALSE; nsAccessNodeHashtable nsAccessNode::gGlobalDocAccessibleCache; nsApplicationAccessibleWrap *nsAccessNode::gApplicationAccessible = nsnull; -nsIAccessibilityService *nsAccessNode::sAccService = nsnull; -nsIAccessibilityService *nsAccessNode::GetAccService() +nsIAccessibilityService* +nsAccessNode::GetAccService() { - if (!gIsAccessibilityActive) - return nsnull; - - if (!sAccService) { - nsresult rv = CallGetService("@mozilla.org/accessibilityService;1", - &sAccService); - NS_ASSERTION(NS_SUCCEEDED(rv), "No accessibility service"); - } - - return sAccService; + return nsAccessibilityService::GetAccessibilityService(); } /* @@ -245,9 +237,7 @@ NS_IMETHODIMP nsAccessNode::GetOwnerWindow(void **aWindow) already_AddRefed nsAccessNode::GetApplicationAccessible() { - if (!gIsAccessibilityActive) { - return nsnull; - } + NS_ASSERTION(gIsAccessibilityActive, "Accessibility wasn't initialized!"); if (!gApplicationAccessible) { nsApplicationAccessibleWrap::PreCreate(); @@ -273,9 +263,8 @@ nsAccessNode::GetApplicationAccessible() void nsAccessNode::InitXPAccessibility() { - if (gIsAccessibilityActive) { - return; - } + NS_ASSERTION(!gIsAccessibilityActive, + "Accessibility was initialized already!"); nsCOMPtr stringBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID); @@ -297,11 +286,13 @@ void nsAccessNode::InitXPAccessibility() prefBranch->GetBoolPref("browser.formfill.enable", &gIsFormFillEnabled); } +#ifdef DEBUG gIsAccessibilityActive = PR_TRUE; - NotifyA11yInitOrShutdown(); +#endif + NotifyA11yInitOrShutdown(PR_TRUE); } -void nsAccessNode::NotifyA11yInitOrShutdown() +void nsAccessNode::NotifyA11yInitOrShutdown(PRBool aIsInit) { nsCOMPtr obsService = do_GetService("@mozilla.org/observer-service;1"); @@ -310,7 +301,7 @@ void nsAccessNode::NotifyA11yInitOrShutdown() static const PRUnichar kInitIndicator[] = { '1', 0 }; static const PRUnichar kShutdownIndicator[] = { '0', 0 }; obsService->NotifyObservers(nsnull, "a11y-init-or-shutdown", - gIsAccessibilityActive ? kInitIndicator : kShutdownIndicator); + aIsInit ? kInitIndicator : kShutdownIndicator); } } @@ -320,16 +311,12 @@ void nsAccessNode::ShutdownXPAccessibility() // which happens when xpcom is shutting down // at exit of program - if (!gIsAccessibilityActive) { - return; - } - gIsShuttingDownApp = PR_TRUE; + NS_ASSERTION(gIsAccessibilityActive, "Accessibility was shutdown already!"); NS_IF_RELEASE(gStringBundle); NS_IF_RELEASE(gKeyStringBundle); NS_IF_RELEASE(gDoCommandTimer); NS_IF_RELEASE(gLastFocusedNode); - NS_IF_RELEASE(sAccService); nsApplicationAccessibleWrap::Unload(); ClearCache(gGlobalDocAccessibleCache); @@ -339,8 +326,10 @@ void nsAccessNode::ShutdownXPAccessibility() NS_IF_RELEASE(gApplicationAccessible); gApplicationAccessible = nsnull; +#ifdef DEBUG gIsAccessibilityActive = PR_FALSE; - NotifyA11yInitOrShutdown(); +#endif + NotifyA11yInitOrShutdown(PR_FALSE); } PRBool diff --git a/accessible/src/base/nsAccessNode.h b/accessible/src/base/nsAccessNode.h index 46f9e2270e5b..da3ecb5faf9f 100644 --- a/accessible/src/base/nsAccessNode.h +++ b/accessible/src/base/nsAccessNode.h @@ -174,21 +174,21 @@ protected: /** * Notify global nsIObserver's that a11y is getting init'd or shutdown */ - static void NotifyA11yInitOrShutdown(); + static void NotifyA11yInitOrShutdown(PRBool aIsInit); // Static data, we do our own refcounting for our static data static nsIStringBundle *gStringBundle; static nsIStringBundle *gKeyStringBundle; static nsITimer *gDoCommandTimer; +#ifdef DEBUG static PRBool gIsAccessibilityActive; - static PRBool gIsShuttingDownApp; +#endif static PRBool gIsCacheDisabled; static PRBool gIsFormFillEnabled; static nsAccessNodeHashtable gGlobalDocAccessibleCache; private: - static nsIAccessibilityService *sAccService; static nsApplicationAccessibleWrap *gApplicationAccessible; }; diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 4cebad4ac760..116bc73d5e82 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -113,6 +113,7 @@ #endif nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull; +PRBool nsAccessibilityService::gIsShutdown = PR_TRUE; /** * nsAccessibilityService @@ -120,6 +121,7 @@ nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull; nsAccessibilityService::nsAccessibilityService() { + // Add observers. nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1"); if (!observerService) @@ -132,13 +134,15 @@ nsAccessibilityService::nsAccessibilityService() nsIWebProgress::NOTIFY_STATE_DOCUMENT | nsIWebProgress::NOTIFY_LOCATION); } + + // Initialize accessibility. nsAccessNodeWrap::InitAccessibility(); } nsAccessibilityService::~nsAccessibilityService() { - nsAccessibilityService::gAccessibilityService = nsnull; - nsAccessNodeWrap::ShutdownAccessibility(); + NS_ASSERTION(gIsShutdown, "Accessibility wasn't shutdown!"); + gAccessibilityService = nsnull; } NS_IMPL_THREADSAFE_ISUPPORTS5(nsAccessibilityService, nsIAccessibilityService, nsIAccessibleRetrieval, @@ -151,6 +155,8 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { + + // Remove observers. nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1"); if (observerService) { @@ -159,8 +165,8 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic, nsCOMPtr progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID)); if (progress) progress->RemoveProgressListener(static_cast(this)); - nsAccessNodeWrap::ShutdownAccessibility(); - // Cancel and release load timers + + // Cancel and release load timers. while (mLoadTimers.Count() > 0 ) { nsCOMPtr timer = mLoadTimers.ObjectAt(0); void *closure = nsnull; @@ -172,7 +178,18 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic, timer->Cancel(); mLoadTimers.RemoveObjectAt(0); } + + // Application is going to be closed, shutdown accessibility and mark + // accessibility service as shutdown to prevent calls of its methods. + // Don't null accessibility service static member at this point to be safe + // if someone will try to operate with it. + + NS_ASSERTION(!gIsShutdown, "Accessibility was shutdown already"); + + gIsShutdown = PR_TRUE; + nsAccessNodeWrap::ShutdownAccessibility(); } + return NS_OK; } @@ -182,7 +199,8 @@ NS_IMETHODIMP nsAccessibilityService::OnStateChange(nsIWebProgress *aWebProgress { NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded"); - if (!aWebProgress || 0 == (aStateFlags & (STATE_START | STATE_STOP))) { + if (gIsShutdown || !aWebProgress || + (aStateFlags & (STATE_START | STATE_STOP)) == 0) { return NS_OK; } @@ -260,23 +278,26 @@ nsAccessibilityService::FireAccessibleEvent(PRUint32 aEvent, void nsAccessibilityService::StartLoadCallback(nsITimer *aTimer, void *aClosure) { - nsIAccessibilityService *accService = nsAccessNode::GetAccService(); - if (accService) - accService->ProcessDocLoadEvent(aTimer, aClosure, nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START); + if (gAccessibilityService) + gAccessibilityService-> + ProcessDocLoadEvent(aTimer, aClosure, + nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_START); } void nsAccessibilityService::EndLoadCallback(nsITimer *aTimer, void *aClosure) { - nsIAccessibilityService *accService = nsAccessNode::GetAccService(); - if (accService) - accService->ProcessDocLoadEvent(aTimer, aClosure, nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE); + if (gAccessibilityService) + gAccessibilityService-> + ProcessDocLoadEvent(aTimer, aClosure, + nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE); } void nsAccessibilityService::FailedLoadCallback(nsITimer *aTimer, void *aClosure) { - nsIAccessibilityService *accService = nsAccessNode::GetAccService(); - if (accService) - accService->ProcessDocLoadEvent(aTimer, aClosure, nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED); + if (gAccessibilityService) + gAccessibilityService-> + ProcessDocLoadEvent(aTimer, aClosure, + nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED); } /* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */ @@ -1315,7 +1336,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode, NS_ENSURE_ARG_POINTER(aAccessible); NS_ENSURE_ARG_POINTER(aFrameHint); *aAccessible = nsnull; - if (!aPresShell || !aWeakShell) { + if (!aPresShell || !aWeakShell || gIsShutdown) { return NS_ERROR_FAILURE; } @@ -2056,22 +2077,28 @@ NS_IMETHODIMP nsAccessibilityService::InvalidateSubtreeFor(nsIPresShell *aShell, nsresult nsAccessibilityService::GetAccessibilityService(nsIAccessibilityService** aResult) { - NS_PRECONDITION(aResult != nsnull, "null ptr"); - if (! aResult) - return NS_ERROR_NULL_POINTER; - + NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER); *aResult = nsnull; - if (!nsAccessibilityService::gAccessibilityService) { + + if (!gAccessibilityService) { gAccessibilityService = new nsAccessibilityService(); - if (!gAccessibilityService ) { - return NS_ERROR_OUT_OF_MEMORY; - } + NS_ENSURE_TRUE(gAccessibilityService, NS_ERROR_OUT_OF_MEMORY); + + gIsShutdown = PR_FALSE; } - *aResult = nsAccessibilityService::gAccessibilityService; - NS_ADDREF(*aResult); + + NS_ADDREF(*aResult = gAccessibilityService); return NS_OK; } +nsIAccessibilityService* +nsAccessibilityService::GetAccessibilityService() +{ + NS_ASSERTION(!gIsShutdown, + "Going to deal with shutdown accessibility service!"); + return gAccessibilityService; +} + nsresult NS_GetAccessibilityService(nsIAccessibilityService** aResult) { diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h index 6b673d5c13bf..9bd43b7bfc98 100644 --- a/accessible/src/base/nsAccessibilityService.h +++ b/accessible/src/base/nsAccessibilityService.h @@ -84,6 +84,16 @@ public: */ static nsresult GetAccessibilityService(nsIAccessibilityService** aResult); + /** + * Return cached accessibility service. + */ + static nsIAccessibilityService* GetAccessibilityService(); + + /** + * Indicates whether accessibility service was shutdown. + */ + static PRBool gIsShutdown; + private: /** * Return presentation shell, DOM node for the given frame. diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 5da571d6bedf..0977c237408d 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -39,7 +39,7 @@ #include "nsRootAccessible.h" #include "nsAccessibilityAtoms.h" #include "nsAccessibleEventData.h" -#include "nsIAccessibilityService.h" +#include "nsAccessibilityService.h" #include "nsIMutableArray.h" #include "nsICommandManager.h" #include "nsIDocShell.h" @@ -670,7 +670,7 @@ nsDocAccessible::Shutdown() // Remove from the cache after other parts of Shutdown(), so that Shutdown() procedures // can find the doc or root accessible in the cache if they need it. // We don't do this during ShutdownAccessibility() because that is already clearing the cache - if (!gIsShuttingDownApp) + if (!nsAccessibilityService::gIsShutdown) gGlobalDocAccessibleCache.Remove(static_cast(kungFuDeathGripDoc)); return NS_OK; diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index ec3257aa7ef0..5b71f9049ebb 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -157,9 +157,12 @@ NS_IMETHODIMP nsRootAccessible::GetParent(nsIAccessible * *aParent) NS_ENSURE_ARG_POINTER(aParent); *aParent = nsnull; - nsRefPtr root = GetApplicationAccessible(); - NS_IF_ADDREF(*aParent = root); + if (!mParent) { + nsRefPtr root = GetApplicationAccessible(); + mParent = root; + } + NS_IF_ADDREF(*aParent = mParent); return NS_OK; } @@ -956,14 +959,12 @@ void nsRootAccessible::FireFocusCallback(nsITimer *aTimer, void *aClosure) nsresult nsRootAccessible::Init() { - nsresult rv = nsDocAccessibleWrap::Init(); - NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr root = GetApplicationAccessible(); NS_ENSURE_STATE(root); root->AddRootAccessible(this); - return NS_OK; + + return nsDocAccessibleWrap::Init(); } nsresult diff --git a/accessible/src/base/nsTextEquivUtils.cpp b/accessible/src/base/nsTextEquivUtils.cpp index ec73a3fe580a..a1ca0c23a4db 100644 --- a/accessible/src/base/nsTextEquivUtils.cpp +++ b/accessible/src/base/nsTextEquivUtils.cpp @@ -336,21 +336,33 @@ nsTextEquivUtils::AppendFromValue(nsIAccessible *aAccessible, NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED; } - nsCOMPtr nextSibling; - aAccessible->GetNextSibling(getter_AddRefs(nextSibling)); - if (nextSibling) { - nsCOMPtr parent; - aAccessible->GetParent(getter_AddRefs(parent)); - if (parent) { - nsCOMPtr firstChild; - parent->GetFirstChild(getter_AddRefs(firstChild)); - if (firstChild && firstChild != aAccessible) { - nsresult rv = aAccessible->GetValue(text); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr acc = nsAccUtils::QueryAccessible(aAccessible); + nsCOMPtr node; + acc->GetDOMNode(getter_AddRefs(node)); + NS_ENSURE_STATE(node); - return AppendString(aString, text) ? - NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED; + nsCOMPtr content(do_QueryInterface(node)); + NS_ENSURE_STATE(content); + + nsCOMPtr parent = content->GetParent(); + PRInt32 indexOf = parent->IndexOf(content); + + for (PRInt32 i = indexOf - 1; i >= 0; i--) { + // check for preceding text... + if (!parent->GetChildAt(i)->TextIsOnlyWhitespace()) { + PRUint32 childCount = parent->GetChildCount(); + for (PRUint32 j = indexOf + 1; j < childCount; j++) { + // .. and subsequent text + if (!parent->GetChildAt(j)->TextIsOnlyWhitespace()) { + nsresult rv = aAccessible->GetValue(text); + NS_ENSURE_SUCCESS(rv, rv); + + return AppendString(aString, text) ? + NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED; + break; + } } + break; } } diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index 79d7b5b51cb7..650efedaf9b6 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -1023,19 +1023,20 @@ void nsHTMLComboboxAccessible::CacheChildren() if (!mListAccessible) { mListAccessible = new nsHTMLComboboxListAccessible(mParent, mDOMNode, mWeakShell); + if (!mListAccessible) + return; + + mListAccessible->Init(); } + #ifdef COMBO_BOX_WITH_THREE_CHILDREN buttonAccessible->SetNextSibling(mListAccessible); #else SetFirstChild(mListAccessible); #endif - if (!mListAccessible) { - return; - } mListAccessible->SetParent(this); mListAccessible->SetNextSibling(nsnull); - mListAccessible->Init(); ++ mAccChildCount; // List accessible child successfully added } diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp index c0d5b581a524..c58d57e74fcb 100644 --- a/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -593,9 +593,8 @@ __try { void nsAccessNodeWrap::InitAccessibility() { - if (gIsAccessibilityActive) { - return; - } + NS_ASSERTION(!gIsAccessibilityActive, + "Accessibility was initialized already!"); nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (prefBranch) { @@ -623,9 +622,7 @@ void nsAccessNodeWrap::ShutdownAccessibility() NS_IF_RELEASE(gTextEvent); ::DestroyCaret(); - if (!gIsAccessibilityActive) { - return; - } + NS_ASSERTION(gIsAccessibilityActive, "Accessibility was shutdown already!"); nsAccessNode::ShutdownXPAccessibility(); } diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js index 856182c0dfaf..66ff30822ea2 100644 --- a/accessible/tests/mochitest/common.js +++ b/accessible/tests/mochitest/common.js @@ -302,9 +302,50 @@ function testAccessibleTree(aAccOrElmOrID, aAccTree) is(children.length, aAccTree.children.length, "Different amount of expected children of " + prettyName(acc) + "."); - if (aAccTree.children.length == children.length) { + if (aAccTree.children.length == children.length) { + var childCount = children.length; + + // nsIAccessible::firstChild + var expectedFirstChild = childCount > 0 ? + children.queryElementAt(0, nsIAccessible) : null; + var firstChild = null; + try { firstChild = acc.firstChild; } catch (e) {} + is(firstChild, expectedFirstChild, + "Wrong first child of " + prettyName(acc)); + + // nsIAccessible::lastChild + var expectedLastChild = childCount > 0 ? + children.queryElementAt(childCount - 1, nsIAccessible) : null; + var lastChild = null; + try { lastChild = acc.lastChild; } catch (e) {} + is(lastChild, expectedLastChild, + "Wrong last child of " + prettyName(acc)); + for (var i = 0; i < children.length; i++) { var child = children.queryElementAt(i, nsIAccessible); + + // nsIAccessible::parent + var parent = null; + try { parent = child.parent; } catch (e) {} + is(parent, acc, "Wrong parent of " + prettyName(child)); + + // nsIAccessible::nextSibling + var expectedNextSibling = (i < childCount - 1) ? + children.queryElementAt(i + 1, nsIAccessible) : null; + var nextSibling = null; + try { nextSibling = child.nextSibling; } catch (e) {} + is(nextSibling, expectedNextSibling, + "Wrong next sibling of " + prettyName(child)); + + // nsIAccessible::previousSibling + var expectedPrevSibling = (i > 0) ? + children.queryElementAt(i - 1, nsIAccessible) : null; + var prevSibling = null; + try { prevSibling = child.previousSibling; } catch (e) {} + is(prevSibling, expectedPrevSibling, + "Wrong previous sibling of " + prettyName(child)); + + // Go down through subtree testAccessibleTree(child, aAccTree.children[i]); } } diff --git a/accessible/tests/mochitest/events.js b/accessible/tests/mochitest/events.js index 249d3958a757..cded4869c80a 100644 --- a/accessible/tests/mochitest/events.js +++ b/accessible/tests/mochitest/events.js @@ -1,6 +1,8 @@ //////////////////////////////////////////////////////////////////////////////// // Constants +const EVENT_DOCUMENT_LOAD_COMPLETE = + nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE; const EVENT_DOM_DESTROY = nsIAccessibleEvent.EVENT_DOM_DESTROY; const EVENT_FOCUS = nsIAccessibleEvent.EVENT_FOCUS; const EVENT_NAME_CHANGE = nsIAccessibleEvent.EVENT_NAME_CHANGE; @@ -86,6 +88,15 @@ function unregisterA11yEventListener(aEventType, aEventHandler) */ const INVOKER_ACTION_FAILED = 1; +/** + * Common invoker checker (see eventSeq of eventQueue). + */ +function invokerChecker(aEventType, aTarget) +{ + this.type = aEventType; + this.target = aTarget; +} + /** * Creates event queue for the given event type. The queue consists of invoker * objects, each of them generates the event of the event type. When queue is @@ -319,7 +330,9 @@ function eventQueue(aEventType) this.setEventHandler = function eventQueue_setEventHandler(aInvoker) { this.mEventSeq = ("eventSeq" in aInvoker) ? - aInvoker.eventSeq : [[this.mDefEventType, aInvoker.DOMNode]]; + aInvoker.eventSeq : + [ new invokerChecker(this.mDefEventType, aInvoker.DOMNode) ]; + this.mEventSeqIdx = -1; if (this.mEventSeq) { @@ -352,20 +365,12 @@ function eventQueue(aEventType) this.getEventType = function eventQueue_getEventType(aIdx) { - var eventItem = this.mEventSeq[aIdx]; - if ("type" in eventItem) - return eventItem.type; - - return eventItem[0]; + return this.mEventSeq[aIdx].type; } this.getEventTarget = function eventQueue_getEventTarget(aIdx) { - var eventItem = this.mEventSeq[aIdx]; - if ("target" in eventItem) - return eventItem.target; - - return eventItem[1]; + return this.mEventSeq[aIdx].target; } this.compareEvents = function eventQueue_compareEvents(aIdx, aEvent) diff --git a/accessible/tests/mochitest/role.js b/accessible/tests/mochitest/role.js index 4c83b63583e4..93415dd13ccb 100644 --- a/accessible/tests/mochitest/role.js +++ b/accessible/tests/mochitest/role.js @@ -3,6 +3,7 @@ const ROLE_ALERT = nsIAccessibleRole.ROLE_ALERT; const ROLE_APPLICATION = nsIAccessibleRole.ROLE_APPLICATION; +const ROLE_APP_ROOT = nsIAccessibleRole.ROLE_APP_ROOT; const ROLE_CELL = nsIAccessibleRole.ROLE_CELL; const ROLE_CHROME_WINDOW = nsIAccessibleRole.ROLE_CHROME_WINDOW; const ROLE_COMBOBOX = nsIAccessibleRole.ROLE_COMBOBOX; diff --git a/accessible/tests/mochitest/test_events_doc.html b/accessible/tests/mochitest/test_events_doc.html index de49ed40498b..b1752c05c50f 100644 --- a/accessible/tests/mochitest/test_events_doc.html +++ b/accessible/tests/mochitest/test_events_doc.html @@ -13,6 +13,8 @@ + @@ -24,6 +26,10 @@ { this.DOMNode = getNode(aIdentifier); + this.eventSeq = [ + new invokerChecker(EVENT_REORDER, getAccessible(this.DOMNode)) + ]; + this.invoke = function changeIframeSrc_invoke() { this.DOMNode.src = aURL; @@ -35,6 +41,49 @@ } } + function openDialogWnd(aURL) + { + // Get application root accessible. + var docAcc = getAccessible(document); + while (docAcc) { + this.mRootAcc = docAcc; + docAcc = docAcc.parent; + } + + this.eventSeq = [ + new invokerChecker(EVENT_REORDER, this.mRootAcc) + ]; + + this.invoke = function openDialogWnd_invoke() + { + this.mDialog = window.openDialog(aURL); + } + + this.check = function openDialogWnd_check() + { + var accTree = { + role: ROLE_APP_ROOT, + children: [ + { + role: ROLE_CHROME_WINDOW + }, + { + role: ROLE_CHROME_WINDOW + } + ] + }; + + testAccessibleTree(this.mRootAcc, accTree); + + this.mDialog.close(); + } + + this.getID = function openDialogWnd_getID() + { + return "open dialog '" + aURL + "'"; + } + } + //////////////////////////////////////////////////////////////////////////// // Do tests @@ -44,10 +93,11 @@ function doTests() { - gQueue = new eventQueue(EVENT_REORDER); + gQueue = new eventQueue(); gQueue.push(new changeIframeSrc("iframe", "about:")); gQueue.push(new changeIframeSrc("iframe", "about:buildconfig")); + gQueue.push(new openDialogWnd("about:")); gQueue.invoke(); // Will call SimpleTest.finish(); } @@ -64,6 +114,11 @@ title="Fire event_reorder on any embedded frames/iframes whos document has just loaded"> Mozilla Bug 420845 + + Mozilla Bug 506206 +

diff --git a/accessible/tests/mochitest/test_events_mutation.html b/accessible/tests/mochitest/test_events_mutation.html index 399f829d967f..597edd63d105 100644 --- a/accessible/tests/mochitest/test_events_mutation.html +++ b/accessible/tests/mochitest/test_events_mutation.html @@ -60,8 +60,8 @@ { var type = this.getA11yEventType(aEventType); for (var idx = 0; idx < this.eventSeq.length; idx++) { - if (this.eventSeq[idx][0] == type) { - this.eventSeq[idx][1] = aTarget; + if (this.eventSeq[idx].type == type) { + this.eventSeq[idx].target = aTarget; return idx; } } @@ -76,8 +76,10 @@ var targetIdx = this.setTarget(aEventType, aTargets[0]); var type = this.getA11yEventType(aEventType); - for (var i = 1; i < aTargets.length; i++) - this.eventSeq.splice(++targetIdx, 0, [type, aTargets[i]]); + for (var i = 1; i < aTargets.length; i++) { + var checker = new invokerChecker(type, aTargets[i]); + this.eventSeq.splice(++targetIdx, 0, checker); + } } // Implementation @@ -103,15 +105,23 @@ this.mIsDOMChange = aIsDOMChange; - if (aEventTypes & kHideEvent) - this.eventSeq.push([this.getA11yEventType(kHideEvent), this.DOMNode]); + if (aEventTypes & kHideEvent) { + var checker = new invokerChecker(this.getA11yEventType(kHideEvent), + this.DOMNode); + this.eventSeq.push(checker); + } - if (aEventTypes & kShowEvent) - this.eventSeq.push([this.getA11yEventType(kShowEvent), this.DOMNode]); + if (aEventTypes & kShowEvent) { + var checker = new invokerChecker(this.getA11yEventType(kShowEvent), + this.DOMNode); + this.eventSeq.push(checker); + } - if (aEventTypes & kReorderEvent) - this.eventSeq.push([this.getA11yEventType(kReorderEvent), - this.DOMNode.parentNode]); + if (aEventTypes & kReorderEvent) { + var checker = new invokerChecker(this.getA11yEventType(kReorderEvent), + this.DOMNode.parentNode); + this.eventSeq.push(checker); + } } /** diff --git a/accessible/tests/mochitest/test_events_tree.xul b/accessible/tests/mochitest/test_events_tree.xul index ffaae2c897e0..4c46225074f9 100644 --- a/accessible/tests/mochitest/test_events_tree.xul +++ b/accessible/tests/mochitest/test_events_tree.xul @@ -122,7 +122,7 @@ this.getID = function setTreeView_getID() { return "TreeViewChanged"; } - this.eventSeq = [["TreeViewChanged", gTree]]; + this.eventSeq = [ new invokerChecker("TreeViewChanged", gTree) ]; }; /** diff --git a/accessible/tests/mochitest/test_name.html b/accessible/tests/mochitest/test_name.html index 07041fb2e9a8..d97db17ac261 100644 --- a/accessible/tests/mochitest/test_name.html +++ b/accessible/tests/mochitest/test_name.html @@ -139,13 +139,13 @@ // textarea's name should have the value, which initially is specified by // a text child. - testName("textareawithchild", "Story: Foo"); + testName("textareawithchild", "Story Foo is ended."); // new textarea name should reflect the value change. var elem = document.getElementById("textareawithchild"); elem.value = "Bar"; - testName("textareawithchild", "Story: Bar"); + testName("textareawithchild", "Story Bar is ended."); ///////////////////////////////////////////////////////////////////////// // label with nested combobox (test for 'f' item of name computation guide) @@ -153,6 +153,9 @@ testName("comboinstart", "One day(s)."); testName("combo3", "day(s)."); + testName("textboxinstart", "Two days."); + testName("textbox1", "days."); + testName("comboinmiddle", "Subscribe to ATOM feed."); testName("combo4", "Subscribe to ATOM feed."); @@ -163,6 +166,9 @@ testName("comboinend", "This day was sunny"); testName("combo6", "This day was"); + testName("textboxinend", "This day was sunny"); + testName("textbox2", "This day was"); + SimpleTest.finish(); } @@ -345,13 +351,15 @@
-