Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/tracks/text-track-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ class TextTrackDisplay extends Component {
}
this.updateForTrack(captionsSubtitlesTrack);
} else if (descriptionsTrack) {
if (this.getAttribute('aria-live') !== 'assertive') {
this.setAttribute('aria-live', 'assertive');
if (this.getAttribute('aria-live') !== 'polite') {
this.setAttribute('aria-live', 'polite');
}
this.updateForTrack(descriptionsTrack);
}
Expand Down
36 changes: 36 additions & 0 deletions test/unit/tracks/text-track-display.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,3 +620,39 @@ if (!Html5.supportsNativeTextTracks()) {
player.dispose();
});
}

QUnit.test('aria-live is set to "off" for captions/subtitles tracks and "polite" for descriptions tracks', function(assert) {
const player = TestHelpers.makePlayer();
const display = player.textTrackDisplay;

// Stub clearDisplay and updateForTrack so no WebVTT processing occurs
display.clearDisplay = () => {};
display.updateForTrack = () => {};

const tracks = player.textTracks();

// Add a captions track and make it active
player.addRemoteTextTrack({ kind: 'captions', language: 'en', label: 'English' }, true);
tracks[0].mode = 'showing';

display.updateDisplay();
assert.strictEqual(
display.el_.getAttribute('aria-live'),
'off',
'aria-live should be "off" when a captions track is active to avoid interrupting screen reader announcements'
);

// Switch to a descriptions track
tracks[0].mode = 'disabled';
player.addRemoteTextTrack({ kind: 'descriptions', language: 'en', label: 'English Descriptions' }, true);
tracks[1].mode = 'showing';

display.updateDisplay();
assert.strictEqual(
display.el_.getAttribute('aria-live'),
'polite',
'aria-live should be "polite" for descriptions tracks so announcements queue without interrupting other screen reader output'
);

player.dispose();
});