Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Add support to run multiple tests #11

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions core-aam/acacia/blockquote.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<meta charset=utf-8>
<title>core-aam: blockquote role</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>

<body>
<div id=test role=blockquote>quote</div>

<script>
promise_test(async t => {
const node = await test_driver.get_accessibility_api_node('test');

if (node.API == 'atspi') {
assert_equals(node.role, 'block quote', 'Atspi role');
}
else if (node.API == 'axapi') {
assert_equals(node.role, 'AXGroup', 'AX API role');
}
else if (node.API == 'windows') {
assert_equals(node.msaa_role, 'ROLE_SYSTEM_GROUPING', 'MSAA Role');
assert_equals(node.msaa_role, 'IA2_ROLE_BLOCK_QUOTE', 'IA2 Role');
}
else {
assert_unreached(`Unknown API: ${node.API}`)
}
}, 'role blockquote');
</script>
</body>
File renamed without changes.
40 changes: 21 additions & 19 deletions tools/wptrunner/wptrunner/executors/executoratspi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
import sys


def poll_for_active_tab(root, logger, product):
active_tab = find_active_tab(root, product)
while not active_tab:
def poll_for_tab(root, product, url):
tab = find_tab(root, product, url)
while not tab:
time.sleep(0.01)
active_tab = find_active_tab(root, product)
tab = find_tab(root, product, url)

return active_tab
return tab


def find_active_tab(root, product):
def find_tab(root, product, url):
stack = [root]
while stack:
node = stack.pop()
if Atspi.Accessible.get_role_name(node) == "frame":
relationset = Atspi.Accessible.get_relation_set(node)
for relation in relationset:
if relation.get_relation_type() == Atspi.RelationType.EMBEDS:
active_tab = relation.get_target(0)
if is_ready(active_tab, product):
return active_tab
tab = relation.get_target(0)
if is_ready(tab, product, url):
return tab
else:
return None
continue
Expand All @@ -40,20 +40,18 @@ def find_active_tab(root, product):
return None


def is_ready(active_tab, product):
def is_ready(tab, product, url):
# Firefox uses the "BUSY" state to indicate the page is not ready.
if product == "firefox":
state_set = Atspi.Accessible.get_state_set(active_tab)
state_set = Atspi.Accessible.get_state_set(tab)
return not Atspi.StateSet.contains(state_set, Atspi.StateType.BUSY)

# Chromium family browsers do not use "BUSY", but you can
# tell if the document can be queried by Title attribute. If the 'Title'
# tell if the document can be queried by URL attribute. If the 'URL'
# attribute is not here, we need to query for a new accessible object.
# TODO: eventually we should test this against the actual title of the
# page being tested.
document = Atspi.Accessible.get_document_iface(active_tab)
document = Atspi.Accessible.get_document_iface(tab)
document_attributes = Atspi.Document.get_document_attributes(document)
if "Title" in document_attributes and document_attributes["Title"]:
if "URI" in document_attributes and document_attributes["URI"] == url:
return True
return False

Expand Down Expand Up @@ -101,7 +99,9 @@ def setup(self, product_name, logger):
self.product_name = product_name
self.full_app_name = ""
self.root = None
self.found_browser = False
self.document = None
self.test_url = None


(self.root, self.full_app_name) = find_browser(self.product_name)
if not self.root:
Expand All @@ -116,9 +116,11 @@ def get_accessibility_api_node(self, dom_id, url):
f"Couldn't find browser {self.product_name} in accessibility API ATSPI. Did you turn on accessibility?"
)

active_tab = poll_for_active_tab(self.root, self.logger, self.product_name)
if self.test_url != url or not self.document:
self.test_url = url
self.document = poll_for_tab(self.root, self.product_name, url)

node = find_node(active_tab, dom_id)
node = find_node(self.document, dom_id)
if not node:
raise Exception(
f"Couldn't find node with id={dom_id} in accessibility API ATSPI."
Expand Down