Open Bug 1934714 Opened 1 year ago Updated 1 year ago

"Node is not accessible via accessibility API" failure on click in browser popup panel in browser mochitest

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

People

(Reporter: hiro, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

Though honestly I am not sure this is a real a11y failure or a problem in the test, I am filing.

Attaching file is a patch to add a browser-mochitest which tries to click on an element inside a browser panel popup window. If you run the test with --enable-a11y-check you will see;

 0:05.21 FAIL Node is not accessible via accessibility API: id: , tagName: panel, className:  - 
Stack trace:
chrome://mochikit/content/browser-test.js:test_ok:1599
chrome://mochikit/content/tests/SimpleTest/AccessibilityUtils.js:a11yFail:755
chrome://mochikit/content/tests/SimpleTest/AccessibilityUtils.js:assertCanBeClicked:1164
chrome://mochikit/content/tests/SimpleTest/AccessibilityUtils.js:runIfA11YChecks/this.AccessibilityUtils:1140
chrome://mochikit/content/tests/SimpleTest/AccessibilityUtils.js:handleEvent:1257
EventListener.handleEvent*chrome://mochikit/content/tests/SimpleTest/AccessibilityUtils.js:init:1217
chrome://mochikit/content/browser-test.js:Tester:170
chrome://mochikit/content/browser-harness.xhtml:createTester/</<:261

I am on Linux Wayland, FWIW.

A11y checks works by adding a capturing click listener and examining the composedTarget of captured click events. In this case, the event's composedTarget is the panel. I would have expected it to be div#container. I don't understand why it isn't.

If this indeed a fundamental problem with a11y checks, I'm really, really surprised we haven't seen it in hundreds of other browser tests. Anna, do you know of tests we had to disable because of this <panel> problem? have I been living under a rock and somehow missed that a11y checks has always been broken in pop-up panels?

Flags: needinfo?(ayeddi)

If you use EventUtils.synthesizeMouseAtCenter, we get div#containre as the composedTarget as expected. But if you use .synthesizeNativeMouseEvent (which uses widget events), we get the panel as the composedTarget.

Severity: -- → S3
Flags: needinfo?(echen)

(In reply to James Teh [:Jamie] from comment #1)

A11y checks works by adding a capturing click listener and examining the composedTarget of captured click events. In this case, the event's composedTarget is the panel. I would have expected it to be div#container. I don't understand why it isn't.

If this indeed a fundamental problem with a11y checks, I'm really, really surprised we haven't seen it in hundreds of other browser tests. Anna, do you know of tests we had to disable because of this <panel> problem? have I been living under a rock and somehow missed that a11y checks has always been broken in pop-up panels?

I think this test is clicking an empty container (per the patch attached - :hiro, please correct me if I'm wrong). In this case, there is no accessible element to click on - we could follow this case in the a11y-checks FAQ docs and add an exception.

If the test is supposed to be clicking something clickable, please point me to that place in the code so I could investigate. Sometimes, panels are not yet created when the test click comes through too - this is a test harness limitation (way faster than a real human would be clicking on things), in that case, we'd need to wait for the panel to be ready, etc.

Flags: needinfo?(ayeddi) → needinfo?(hikezoe.birchill)

I am not 100% sure I understand what accessible elements are exactly, given that a div element having "click" event listener is not accessible, then I would say a11y-checkes should ignore it.

(In reply to Anna Yeddi [:ayeddi] from comment #3)

If the test is supposed to be clicking something clickable, please point me to that place in the code so I could investigate. Sometimes, panels are not yet created when the test click comes through too - this is a test harness limitation (way faster than a real human would be clicking on things), in that case, we'd need to wait for the panel to be ready, etc.

It is possible that elements inside popup windows are not ready to be used in terms of a11y. Presumably with --enable-a11y-check we need to wait the ready state as you said, I guess the places is not specific to popup windows, I suppose it should be inside EventUtils.synthesizeBlah functions.

Flags: needinfo?(hikezoe.birchill)

Though I don't yet understand why the a11y check works with synthesizeMouseAtCenter.

(In reply to Anna Yeddi [:ayeddi] from comment #3)

I think this test is clicking an empty container (per the patch attached - :hiro, please correct me if I'm wrong). In this case, there is no accessible element to click on

There is a generic (the div), which is a separate problem. But that isn't the first issue here, which is that a11y checks only sees the panel. Even if you give the div role="button" tabindex="0", a11y checks still fails on the panel.

(In reply to Hiroyuki Ikezoe (:hiro) from comment #4)

I am not 100% sure I understand what accessible elements are exactly, given that a div element having "click" event listener is not accessible, then I would say a11y-checkes should ignore it.

A11y checks are designed to ensure that anything interactive is also accessible; i.e. it has proper semantics and focusability. If a UI test clicks on a clickable div with no semantics, that means that div is inaccessible to some users, so it's a failure. So, even once we sort out the issue with the target being the panel instead of the div, you will need to fix the test to give the div proper semantics (e.g. make it a button or give it role="button" tabindex="0"). Otherwise, you'll get a different (valid) failure.

It is possible that elements inside popup windows are not ready to be used in terms of a11y.

I don't think that's the problem here, though it may end up being one after we fix the other problems.

(In reply to Hiroyuki Ikezoe (:hiro) from comment #5)

Though I don't yet understand why the a11y check works with synthesizeMouseAtCenter.

Yeah, that's where things get weird and is the piece I don't understand yet.

(In reply to James Teh [:Jamie] from comment #2)

If you use EventUtils.synthesizeMouseAtCenter, we get div#containre as the composedTarget as expected. But if you use .synthesizeNativeMouseEvent (which uses widget events), we get the panel as the composedTarget.

It seems the event isn’t dispatched to the expected coordinates if we synthesize the event immediately after receiving the popupshown event.
I dumped the coordinates of the div#container both right after receiving the popupshown event and after receiving the click event, e.g.

  ...

  await popupshownPromise;
 
  const rect1 = container.getBoundingClientRect();
  info(`${rect1.width}, ${rect1.height}, ${rect1.left}, ${rect1.top}`);      // <========= after receiving popupshown

  await EventUtils.synthesizeNativeMouseEvent({
    type: "click",
    target: container,
    atCenter: true,
  });
  await clickPromise;

  const rect2 = container.getBoundingClientRect();
  info(`${rect2.width}, ${rect2.height}, ${rect2.left}, ${rect2.top}`);      // <========= after receiving click

  ...

I noticed a 70px shift in the coordinates.

100, 100, 1245, 48     <==== after receiving the `popupshown` event
100, 100, 1175, 48     <==== after `click` event.

It happens regardless of whether we use EventUtils.synthesizeMouseAtCenter() or .synthesizeNativeMouseEvent(). However, .synthesizeMouseAtCenter() dispatches the event synchronously, whereas .synthesizeNativeMouseEvent() dispatches it asynchronously. I think this might be why they produce different results in hit testing.

And if you put some delay before synthesizing the mouse event, e.g.

  ...

  await popupshownPromise;
  await new Promise(resolve => setTimeout(resolve, 0));      // <====== put a delay here

  await EventUtils.synthesizeNativeMouseEvent({
    type: "click",
    target: container,
    atCenter: true,
  });
  await clickPromise;
  ...

Then everything works fine.

I could only reproduce this on Wayland Linux only, not on X11 Linux or macOS.
It looks like a layout or xul popup (?) issue on Wayland Linux to me. The layout isn't stable yet when the popupshown is dispatched on Wayland Linux?

Flags: needinfo?(echen)

Thanks for looking into this.

(In reply to Edgar Chen [:edgar] from comment #7)

It seems the event isn’t dispatched to the expected coordinates if we synthesize the event immediately after receiving the popupshown event.

But curiously, the click event still fires on the correct node itself - i.e. clickPromise does resolve - even though the A11yUtils capturing click listener gets the wrong node. Does that not mean hit testing succeeds? or do we actually pass the node to the event and so the event can be dispatched to the right node regardless of hit testing?

It looks like a layout or xul popup (?) issue on Wayland Linux to me. The layout isn't stable yet when the popupshown is dispatched on Wayland Linux?

It seems that way. I don't think there's anything we can do in accessibility to fix this. :hiro, you could try waiting for an accessibility EVENT_SHOW on the pop-up, which might be more reliable because accessibility timing is aligned more closely with layout than DOM. But that would be tricky outside of accessible/tests; I'm not sure where you plan to put this test eventually.

:hiro, let me know what your plans are here. If you need help with an accessibility event workaround in the test, I'm happy to help. Otherwise, I think we should morph this into a Wayland widget bug.

Flags: needinfo?(hikezoe.birchill)

There's nothing blocking my work at all. I originally wrote the test for bug 1682629, but for the bug any click event doesn't need to be involved, because the bug itself is specific to touch events.

(In reply to James Teh [:Jamie] from comment #8)

It looks like a layout or xul popup (?) issue on Wayland Linux to me. The layout isn't stable yet when the popupshown is dispatched on Wayland Linux?

It seems that way. I don't think there's anything we can do in accessibility to fix this. :hiro, you could try waiting for an accessibility EVENT_SHOW on the pop-up, which might be more reliable because accessibility timing is aligned more closely with layout than DOM. But that would be tricky outside of accessible/tests; I'm not sure where you plan to put this test eventually.

Based on this failure on a try run, it does happen with X-Window.

(CCing stransky just in case)

Flags: needinfo?(hikezoe.birchill)

I'm not sure if it's related, but on Wayland popup windows are placed by Waylan compositor, not by Firefox itself. Wayland doesn't provide global coordinates and we don't know where Firefox window is located. We request to show a popup and OS (wayland compositor) returns coordinates and size where the popup is shown. So there's possible delay and also coordinates (and possible size) change.

Blocks: a11y-checks

I happened to remember this bug while I am working on bug 1943597. In bug 1943597, I am going to add a new variant of nsIDOMWindowUtils.sendMouseEvent. sendMouseEvent is a function used for synthesizeMouseAtCenter. I realized sendMouseEvent doesn't work for popup window, so I need the new variant of the function which can be used for popup.

So, here I am not sure what happened with synthesizeMouseAtCenter, but I am moderately sure with the new function we will see the same failure even if the new function doesn't synthesize any native events.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: