forked from rosa/hakurei
cmd/pkgserver: aria-describe test node summary with state
The summary marker does not appear in the AOM, so setting its alt text is fruitless.
This commit is contained in:
@@ -303,6 +303,7 @@ export class DOMReporter implements Reporter {
|
|||||||
if (!parent) throwNotInDOMError("root");
|
if (!parent) throwNotInDOMError("root");
|
||||||
for (const node of path) {
|
for (const node of path) {
|
||||||
let child: HTMLDetailsElement | null = null;
|
let child: HTMLDetailsElement | null = null;
|
||||||
|
let summary: HTMLElement | null = null;
|
||||||
let d: Element;
|
let d: Element;
|
||||||
outer: for (d of parent.children) {
|
outer: for (d of parent.children) {
|
||||||
if (!(d instanceof HTMLDetailsElement)) continue;
|
if (!(d instanceof HTMLDetailsElement)) continue;
|
||||||
@@ -310,6 +311,7 @@ export class DOMReporter implements Reporter {
|
|||||||
if (!(s instanceof HTMLElement)) continue;
|
if (!(s instanceof HTMLElement)) continue;
|
||||||
if (!(s.tagName === "SUMMARY" && s.innerText === node)) continue;
|
if (!(s.tagName === "SUMMARY" && s.innerText === node)) continue;
|
||||||
child = d;
|
child = d;
|
||||||
|
summary = s;
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,12 +319,13 @@ export class DOMReporter implements Reporter {
|
|||||||
child = document.createElement("details");
|
child = document.createElement("details");
|
||||||
child.className = "test-node";
|
child.className = "test-node";
|
||||||
child.ariaRoleDescription = "test";
|
child.ariaRoleDescription = "test";
|
||||||
const summary = document.createElement("summary");
|
summary = document.createElement("summary");
|
||||||
summary.appendChild(document.createTextNode(node));
|
summary.appendChild(document.createTextNode(node));
|
||||||
summary.ariaRoleDescription = "test name";
|
summary.ariaRoleDescription = "test name";
|
||||||
child.appendChild(summary);
|
child.appendChild(summary);
|
||||||
parent.appendChild(child);
|
parent.appendChild(child);
|
||||||
}
|
}
|
||||||
|
if (!summary) throw new Error("unreachable as assigned above");
|
||||||
|
|
||||||
switch (result.state) {
|
switch (result.state) {
|
||||||
case "failure":
|
case "failure":
|
||||||
@@ -330,17 +333,18 @@ export class DOMReporter implements Reporter {
|
|||||||
child.classList.add("failure");
|
child.classList.add("failure");
|
||||||
child.classList.remove("skip");
|
child.classList.remove("skip");
|
||||||
child.classList.remove("success");
|
child.classList.remove("success");
|
||||||
|
summary.setAttribute("aria-labelledby", "failure-description");
|
||||||
break;
|
break;
|
||||||
case "skip":
|
case "skip":
|
||||||
if (child.classList.contains("failure")) break;
|
if (child.classList.contains("failure")) break;
|
||||||
child.classList.add("skip");
|
child.classList.add("skip");
|
||||||
child.classList.remove("success");
|
child.classList.remove("success");
|
||||||
|
summary.setAttribute("aria-labelledby", "skip-description");
|
||||||
break;
|
break;
|
||||||
case "success":
|
case "success":
|
||||||
if (!(child.classList.contains("failure") ||
|
if (child.classList.contains("failure") || child.classList.contains("skip")) break;
|
||||||
child.classList.contains("skip"))) {
|
child.classList.add("success");
|
||||||
child.classList.add("success");
|
summary.setAttribute("aria-labelledby", "success-description");
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
failed<span id="skip-counter-text" class="hidden">, <span id="skip-counter">0</span> skipped</span>.
|
failed<span id="skip-counter-text" class="hidden">, <span id="skip-counter">0</span> skipped</span>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p hidden id="success-description">Successful test</p>
|
||||||
|
<p hidden id="failure-description">Failed test</p>
|
||||||
|
<p hidden id="skip-description">Partially or fully skipped test</p>
|
||||||
|
|
||||||
<div id="root">
|
<div id="root">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user