diff --git a/.changeset/tasty-stingrays-grab.md b/.changeset/tasty-stingrays-grab.md new file mode 100644 index 0000000000..b724e25746 --- /dev/null +++ b/.changeset/tasty-stingrays-grab.md @@ -0,0 +1,5 @@ +--- +"@siteimprove/alfa-rules": patch +--- + +**Changed:** Media rules R23 and R29 no longer asks if audio is playing or where the play buttons is when the attributes `autoplay` and `controls` are present respectively. diff --git a/packages/alfa-rules/src/common/applicability/audio.ts b/packages/alfa-rules/src/common/applicability/audio.ts index 335cb4b90b..344a7d0e9a 100644 --- a/packages/alfa-rules/src/common/applicability/audio.ts +++ b/packages/alfa-rules/src/common/applicability/audio.ts @@ -17,7 +17,7 @@ import { Style } from "@siteimprove/alfa-style"; import { Question } from "../act/question"; const { isPerceivableForAll } = DOM; -const { isElement, hasName, hasNamespace } = Element; +const { isElement, hasName, hasNamespace, hasAttribute } = Element; const { and } = Predicate; const { isRendered } = Style; const { getElementDescendants } = Query; @@ -44,17 +44,21 @@ export function audio( Question.of("is-audio-streaming", element).map((isStreaming) => isStreaming ? None - : Question.of("is-playing", element).map((isPlaying) => - isPlaying - ? Option.of(element) - : Question.of("play-button", element).map((playButton) => - playButton.some( - and(isElement, isPerceivableForAll(device)), - ) - ? Option.of(element) - : None, - ), - ), + : Question.of("is-playing", element) + .answerIf(hasAttribute("autoplay"), true) + .map((isPlaying) => + isPlaying + ? Option.of(element) + : Question.of("play-button", element) + .answerIf(hasAttribute("controls"), Option.of(element)) + .map((playButton) => + playButton.some( + and(isElement, isPerceivableForAll(device)), + ) + ? Option.of(element) + : None, + ), + ), ), ), ); diff --git a/packages/alfa-rules/test/sia-r23/rule.spec.tsx b/packages/alfa-rules/test/sia-r23/rule.spec.tsx index c60a0c6d19..7cc75c172f 100755 --- a/packages/alfa-rules/test/sia-r23/rule.spec.tsx +++ b/packages/alfa-rules/test/sia-r23/rule.spec.tsx @@ -37,6 +37,59 @@ test(`evaluate() passes an audio with perceivable transcript`, async (t) => { ); }); +test(`evaluate() passes an audio with autoplay attribute and with perceivable transcript`, async (t) => { + const target =