Skip to content

Add aam tests for link elements in core-aam#60490

Open
tannal wants to merge 1 commit into
web-platform-tests:masterfrom
tannal:core-aam-link
Open

Add aam tests for link elements in core-aam#60490
tannal wants to merge 1 commit into
web-platform-tests:masterfrom
tannal:core-aam-link

Conversation

@tannal

@tannal tannal commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This change added a test for role mapping of the hyperlink element.

See https://w3c.github.io/core-aam/#role-map-link

cc @spectranaut

@spectranaut spectranaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@spectranaut spectranaut Jun 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@spectranaut spectranaut Jun 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants