Add aam tests for link elements in core-aam#60490
Conversation
spectranaut
left a comment
There was a problem hiding this comment.
Great start! If we are going to merge this test, it would be better to test all the mappings in Core-AAM for link, I explained each of them.
| session.url = inline(test_html) | ||
|
|
||
| node = atspi.find_node("test", session.url) | ||
| assert atspi.Accessible.get_role(node) == atspi.Role.LINK |
There was a problem hiding this comment.
There is actually one more line in CORE-AAM we need to check, which is whether the interface HyperlinkImpl is supported:
assert atspi.Accessible.get_hypertext_iface(node) is not None
See: https://docs.gtk.org/atspi2/method.Accessible.get_hypertext_iface.html
| import pytest | ||
|
|
||
| TEST_HTML = { | ||
| "native-anchor": "<a id=test href='https://example.com'>click me</a>", |
There was a problem hiding this comment.
The mapping of the html element a happens in a different spec, so the test needs to be in a different folder -- specifically the html-aam one: https://w3c.github.io/html-aam/#el-a
The infrastructure to run these tests isn't there yet, but you could add it the same way you are adding it to the mathml directory. Otherwise, you can copy this test basically as is, because the assertions will be the same for both.
| node = axapi.find_node("test", session.url) | ||
|
|
||
| role = axapi.AXUIElementCopyAttributeValue(node, "AXRole", None)[1] | ||
| assert role == "AXLink" |
There was a problem hiding this comment.
Similarly, you should add a test for the subrole, here: AXSubrole:
subrole = axapi.AXUIElementCopyAttributeValue(node, "AXSubrole", None)[1]
assert subrole == None
| session.url = inline(test_html) | ||
| node = ia2.find_node("test", session.url) | ||
|
|
||
| assert ia2.get_role(node) == "ROLE_SYSTEM_LINK" No newline at end of file |
There was a problem hiding this comment.
And in this case, you need to check both states and the interface. For the states you can use this utility: https://github.com/web-platform-tests/wpt/blob/master/core-aam/aamtests/support/ia2_wrapper.py#L104
For the interface, it's a bit more complicated. You will probably want to write a utility to do it, in the same file.
I can't easily test on Windows right now, this is my guess for what you will need to add it ia2_wrapper, I'm think it will return None when not supported -- but do you have a windows machine to test locally?
# add to ia2 imports
from ia2 import IAccessibleHyperlink
# this is a type alias, just for clarity when reading the function definitions
IAccessibleHyperlinkPtr = Any
# add to class IA2Wrapper
def get_hyperlink_interface(self, IAccessible2Ptr) -> IAccessibleHyperlinkPtr:
service = node.QueryInterface(IServiceProvider)
return service.QueryService(IAccessible._iid_, IAccessibleHyperlink)
This change added a test for role mapping of the hyperlink element.
See https://w3c.github.io/core-aam/#role-map-link
cc @spectranaut