From 76984837ea7e89a6d4347005c12bbb7a62761cc0 Mon Sep 17 00:00:00 2001 From: l3onhard Date: Wed, 15 Oct 2025 22:40:36 +0200 Subject: [PATCH] fix(curriculum): add test to ensure typeAttr matches srcAttr media type (#62512) Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com> Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> --- .../68de40f53fcaf106f51cc20f.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/curriculum/challenges/english/blocks/lab-html-audio-and-video-player/68de40f53fcaf106f51cc20f.md b/curriculum/challenges/english/blocks/lab-html-audio-and-video-player/68de40f53fcaf106f51cc20f.md index ea966be06b1..d9c8388b2d5 100644 --- a/curriculum/challenges/english/blocks/lab-html-audio-and-video-player/68de40f53fcaf106f51cc20f.md +++ b/curriculum/challenges/english/blocks/lab-html-audio-and-video-player/68de40f53fcaf106f51cc20f.md @@ -112,6 +112,25 @@ const typeAttr = source.getAttribute('type'); assert.isNotEmpty(typeAttr); ``` +The `type` attribute should match the media type of the file extension of the `src` attribute. + +```js +const section = document.querySelector('section'); +const source = section?.querySelector('h2 + video > source'); +const typeAttr = source.getAttribute('type'); +const srcAttr = source.getAttribute('src'); +const srcFileExt = srcAttr.match(/[^\.]+$/g)[0]; +const fileExtToMediaTypes = { + mp4: ['video/mp4'], + webm: ['video/webm'], + ogg: ['video/ogg'], + avi: ['video/avi', 'video/vnd.avi', 'video/msvideo', 'video/x-msvideo'], + mov: ['video/quicktime'] +}; +const srcMediaTypes = fileExtToMediaTypes[srcFileExt]; +assert.oneOf(typeAttr, srcMediaTypes); +``` + Inside the second `section` element, you should have an `h2` element for the title of the song playing. ```js