Skip to content

Commit 194cd49

Browse files
authored
Merge branch 'main' into bypass
2 parents f72b38b + 07cd684 commit 194cd49

File tree

42 files changed

+224
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+224
-156
lines changed

generate-act-tests.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ for (const rule of applicableRules) {
165165
throw new Error(`Unknown expected state: ${expected}`);
166166
}
167167

168-
const suite = `import { fixture, expect } from "@open-wc/testing";
168+
const suite = `import { expect } from "@open-wc/testing";
169169
import { scan } from "../../../../src/scanner";
170170
171+
const parser = new DOMParser();
172+
171173
describe("[${ruleId}]${ruleName}", function () {
172174
it("${testcaseTitle} (${exampleURL})", async () => {
173-
await fixture(\`${html}\`);
175+
const document = parser.parseFromString(\`${html}\`, 'text/html');
174176
175177
const results = (await scan(document.body)).map(({ text, url }) => {
176178
return { text, url };

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function isVisible(el: HTMLElement): boolean {
1010
export function labelledByIsValid(el: Element): boolean {
1111
const id = el.getAttribute("aria-labelledby");
1212
if (!id) return false;
13-
const otherElement = querySelector(`#${id}`, document);
13+
const otherElement = querySelector(`#${id}`, el.ownerDocument);
1414
if (!otherElement) return false;
1515

1616
if (otherElement instanceof HTMLSelectElement) return false;
@@ -98,7 +98,7 @@ function recurse(
9898
) {
9999
// if "document" is passed in, it will also pick up "<html>" causing the query to run twice.
100100
if (container instanceof Document) {
101-
container = document.documentElement;
101+
container = container.documentElement;
102102
}
103103

104104
// I haven't figured this one out, but for some reason when using the buildQueries

tests/act/tests/c487ae/014295a8bd7213fdbd69bc1c8ee44c48268370ec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Passed Example 8 (https://act-rules.github.io/testcases/c487ae/014295a8bd7213fdbd69bc1c8ee44c48268370ec.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"><img src="/test-assets/shared/w3c-logo.png" aria-labelledby="id1"/></a>
7-
<div id="id1">Web Accessibility Initiative (WAI)</div>`);
8+
const document = parser.parseFromString(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"><img src="/test-assets/shared/w3c-logo.png" aria-labelledby="id1"/></a>
9+
<div id="id1">Web Accessibility Initiative (WAI)</div>`, 'text/html');
810

911
const results = (await scan(document.body)).map(({ text, url }) => {
1012
return { text, url };

tests/act/tests/c487ae/03653844ceb8f6cd95af81672123ea98323ce5c8.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Passed Example 5 (https://act-rules.github.io/testcases/c487ae/03653844ceb8f6cd95af81672123ea98323ce5c8.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <a href="https://www.w3.org/WAI" title="Web Accessibility Initiative"
8+
const document = parser.parseFromString(`<!DOCTYPE html> <a href="https://www.w3.org/WAI" title="Web Accessibility Initiative"
79
><img src="/test-assets/shared/w3c-logo.png" alt=""
8-
/></a>`);
10+
/></a>`, 'text/html');
911

1012
const results = (await scan(document.body)).map(({ text, url }) => {
1113
return { text, url };

tests/act/tests/c487ae/0d7a7862c5b414c272f1713c341d821f5249a15d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Passed Example 4 (https://act-rules.github.io/testcases/c487ae/0d7a7862c5b414c272f1713c341d821f5249a15d.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"
8+
const document = parser.parseFromString(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"
79
><img src="/test-assets/shared/w3c-logo.png" aria-label="Web Accessibility Initiative"
8-
/></a>`);
10+
/></a>`, 'text/html');
911

1012
const results = (await scan(document.body)).map(({ text, url }) => {
1113
return { text, url };

tests/act/tests/c487ae/113298e42bd5a240371affac3747a470c617610b.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Failed Example 1 (https://act-rules.github.io/testcases/c487ae/113298e42bd5a240371affac3747a470c617610b.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <a href="http://www.w3.org/WAI"></a>`);
8+
const document = parser.parseFromString(`<!DOCTYPE html> <a href="http://www.w3.org/WAI"></a>`, 'text/html');
79

810
const results = (await scan(document.body)).map(({ text, url }) => {
911
return { text, url };

tests/act/tests/c487ae/1752fb0c94ce17c6557a7e498c6e9a87c6a943ea.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Passed Example 10 (https://act-rules.github.io/testcases/c487ae/1752fb0c94ce17c6557a7e498c6e9a87c6a943ea.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <img src="/test-assets/c487ae/planets.jpg" width="145" height="126" alt="Planets" usemap="#planetmap" />
8+
const document = parser.parseFromString(`<!DOCTYPE html> <img src="/test-assets/c487ae/planets.jpg" width="145" height="126" alt="Planets" usemap="#planetmap" />
79
810
<map name="planetmap">
911
<area shape="rect" coords="0,0,30,100" href="sun.htm" alt="Sun" />
10-
</map>`);
12+
</map>`, 'text/html');
1113

1214
const results = (await scan(document.body)).map(({ text, url }) => {
1315
return { text, url };

tests/act/tests/c487ae/2917b821f0e317de992cad191ed67aeedb9f34c9.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Passed Example 7 (https://act-rules.github.io/testcases/c487ae/2917b821f0e317de992cad191ed67aeedb9f34c9.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"
8+
const document = parser.parseFromString(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"
79
><img src="/test-assets/shared/w3c-logo.png" alt="" />Web Accessibility Initiative (WAI)</a
8-
>`);
10+
>`, 'text/html');
911

1012
const results = (await scan(document.body)).map(({ text, url }) => {
1113
return { text, url };

tests/act/tests/c487ae/2bdb0351ae2e82f05cfa15198ca0a353974f6278.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Failed Example 7 (https://act-rules.github.io/testcases/c487ae/2bdb0351ae2e82f05cfa15198ca0a353974f6278.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"><img src="/test-assets/shared/w3c-logo.png" aria-labelledby="id1"/></a>`);
8+
const document = parser.parseFromString(`<!DOCTYPE html> <a href="https://www.w3.org/WAI"><img src="/test-assets/shared/w3c-logo.png" aria-labelledby="id1"/></a>`, 'text/html');
79

810
const results = (await scan(document.body)).map(({ text, url }) => {
911
return { text, url };

tests/act/tests/c487ae/2c58ea9a68f5bf34cabb07059af1a533be96c720.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { fixture, expect } from "@open-wc/testing";
1+
import { expect } from "@open-wc/testing";
22
import { scan } from "../../../../src/scanner";
33

4+
const parser = new DOMParser();
5+
46
describe("[c487ae]Link has non-empty accessible name", function () {
57
it("Passed Example 9 (https://act-rules.github.io/testcases/c487ae/2c58ea9a68f5bf34cabb07059af1a533be96c720.html)", async () => {
6-
await fixture(`<!DOCTYPE html> <html>
8+
const document = parser.parseFromString(`<!DOCTYPE html> <html>
79
<style>
810
.offScreenLink {
911
position: absolute;
@@ -14,7 +16,7 @@ describe("[c487ae]Link has non-empty accessible name", function () {
1416
<body>
1517
<a class="offScreenLink" href="https://www.w3.org/WAI">Web Accessibility Initiative (WAI)</a>
1618
</body>
17-
</html>`);
19+
</html>`, 'text/html');
1820

1921
const results = (await scan(document.body)).map(({ text, url }) => {
2022
return { text, url };

0 commit comments

Comments
 (0)