aria-api

access ARIA information from JavaScript
git clone https://git.ce9e.org/aria-api.git

commit
81a87c2d37b9c683e8b9070938176eb39574b6ee
parent
8996d5ae54a6ea809e3f9c3f7f43db17d660b6b9
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-02-02 19:07
wpt: parse JSON

Diffstat

M wpt.py 31 +++++++++++++++++++++++--------

1 files changed, 23 insertions, 8 deletions


diff --git a/wpt.py b/wpt.py

@@ -30,14 +30,29 @@ def extract_tests(path):
   30    30 				raw = fh.read()
   31    31 
   32    32 				if '<div id="manualMode">' in raw:
   33    -1 					tests.append({
   34    -1 						'filename': filename,
   35    -1 						'title': fenced('<title>', '</title>', raw),
   36    -1 						'html': fenced('<body>', '<div id="manualMode">', raw).strip(),
   37    -1 						'name': get_value('"accName"', raw),
   38    -1 						'description': get_value('"accDescription"', raw),
   39    -1 						'selector': '#test',
   40    -1 					})
   -1    33 					try:
   -1    34 						data = json.loads(fenced('ATTAcomm(', ') ;', raw))
   -1    35 					except json.JSONDecodeError:
   -1    36 						continue
   -1    37 
   -1    38 					for step in data['steps']:
   -1    39 						if step['type'] != 'test':
   -1    40 							continue
   -1    41 						test = {
   -1    42 							'filename': filename,
   -1    43 							'title': data["title"],
   -1    44 							'html': fenced('<body>', '<div id="manualMode">', raw).strip(),
   -1    45 							'name': None,
   -1    46 							'description': None,
   -1    47 							'selector': f'#{step["element"]}',
   -1    48 						}
   -1    49 						for check in step['test'].get('IAccessible2', []):
   -1    50 							if check[1] == 'accName':
   -1    51 								test['name'] = check[3]
   -1    52 							elif check[1] == 'accDescription':
   -1    53 								test['description'] = check[3]
   -1    54 						if len(test) > 4:
   -1    55 							tests.append(test)
   41    56 				elif 'class="ex"' in raw:
   42    57 					tests.append({
   43    58 						'filename': filename,