diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 31eeb4f47ae1..4fb0b4fe53b9 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -317,13 +317,16 @@ nsAccessibilityService::ListenersChanged(nsIArray* aEventChanges) nsIDocument* ownerDoc = node->OwnerDoc(); DocAccessible* document = GetExistingDocAccessible(ownerDoc); - // Create an accessible for a inaccessible element having click event - // handler. - if (document && !document->HasAccessible(node) && - nsCoreUtils::HasClickListener(node)) { - nsIContent* parentEl = node->GetFlattenedTreeParent(); - if (parentEl) { - document->ContentInserted(parentEl, node, node->GetNextSibling()); + // Always recreate for onclick changes. + if (document) { + if (nsCoreUtils::HasClickListener(node)) { + if (!document->GetAccessible(node)) { + document->RecreateAccessible(node); + } + } else { + if (document->GetAccessible(node)) { + document->RecreateAccessible(node); + } } break; } diff --git a/accessible/tests/mochitest/treeupdate/test_bug1175913.html b/accessible/tests/mochitest/treeupdate/test_bug1175913.html index 5dab9b5a8e48..40e20f47b578 100644 --- a/accessible/tests/mochitest/treeupdate/test_bug1175913.html +++ b/accessible/tests/mochitest/treeupdate/test_bug1175913.html @@ -47,7 +47,7 @@ function testRemoveListener() { this.eventSeq = [ - new unexpectedInvokerChecker(EVENT_HIDE, getNode("parent")), + new invokerChecker(EVENT_HIDE, getNode("parent")), ]; this.invoke = function testRemoveListener_invoke() @@ -57,10 +57,8 @@ this.finalCheck = function testRemoveListener_finalCheck() { - ok(getAccessible("parent", null, null, DONOTFAIL_IF_NO_ACC), - "Parent stays accessible after click event listener is removed"); - ok(!getAccessible("child", null, null, DONOTFAIL_IF_NO_ACC), - "Child stays inaccessible"); + is(getAccessible("parent", null, null, DONOTFAIL_IF_NO_ACC), null, "Check that parent is not accessible."); + is(getAccessible("child", null, null, DONOTFAIL_IF_NO_ACC), null, "Check that child is not accessible."); } this.getID = function testRemoveListener_getID() diff --git a/accessible/tests/mochitest/treeupdate/test_textleaf.html b/accessible/tests/mochitest/treeupdate/test_textleaf.html index 4fb62fa74579..fd59f81a86c3 100644 --- a/accessible/tests/mochitest/treeupdate/test_textleaf.html +++ b/accessible/tests/mochitest/treeupdate/test_textleaf.html @@ -43,16 +43,22 @@ var node = getNode(aID); node.setAttribute("onclick", "alert(3);"); var textLeaf = getAccessible(node).firstChild; - is(textLeaf.actionCount, 1, "setOnClickAttr: wrong action numbers!"); + is(textLeaf.actionCount, 1, "Wrong action numbers!"); } function removeOnClickAttr(aID) { - let node = getNode(aID); - node.removeAttribute("onclick"); - let textLeaf = getAccessible(node).firstChild; - is(textLeaf.actionCount, 0, - "removeOnClickAttr: wrong action numbers!"); + this.__proto__ = new textLeafUpdate(aID, false); + + this.invoke = function removeOnClickAttr_invoke() + { + this.node.removeAttribute("onclick"); + } + + this.getID = function removeOnClickAttr_getID() + { + return "unmake " + prettyName(aID) + " linkable"; + } } function setOnClickNRoleAttrs(aID) @@ -123,11 +129,10 @@ { // adds onclick on element, text leaf should inherit its action setOnClickAttr("div"); - // remove onclick attribute, text leaf shouldn't have any action - removeOnClickAttr("div"); - // Call rest of event tests. gQueue = new eventQueue(); + // remove onclick attribute, text leaf shouldn't have any action + gQueue.push(new removeOnClickAttr("div")); // set onclick attribute making span accessible, it's inserted into tree // and adopts text leaf accessible, text leaf should have an action