-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Muting with MuteToggle
sets ARIA value of VolumeBar
to 0
#4099
Changes from 2 commits
f1f6451
da8516d
0c5f3cc
6309a76
0dabd59
c3ebcc7
c963d02
2b8f064
80fb9d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* eslint-env qunit */ | ||
import VolumeControl from '../../src/js/control-bar/volume-control/volume-control.js'; | ||
import MuteToggle from '../../src/js/control-bar/mute-toggle.js'; | ||
import VolumeBar from '../../src/js/control-bar/volume-control/volume-bar.js'; | ||
import PlaybackRateMenuButton from '../../src/js/control-bar/playback-rate-menu/playback-rate-menu-button.js'; | ||
import Slider from '../../src/js/slider/slider.js'; | ||
import FullscreenToggle from '../../src/js/control-bar/fullscreen-toggle.js'; | ||
|
@@ -138,4 +139,34 @@ if (Html5.isSupported()) { | |
assert.equal(player.volume(), 0.5, 'volume is set to lastVolume'); | ||
assert.equal(player.muted(), false, 'muted is set to false'); | ||
}); | ||
|
||
QUnit.test('ARIA value of VolumeBar should start at 100', function(assert) { | ||
const player = TestHelpers.makePlayer({ techOrder: ['html5'] }); | ||
const volumeBar = new VolumeBar(player); | ||
|
||
volumeBar.updateARIAAttributes(); | ||
|
||
assert.equal(volumeBar.el_.getAttribute('aria-valuenow'), 100, 'ARIA value of VolumeBar is 100'); | ||
}); | ||
|
||
QUnit.test('Muting with MuteToggle should set ARIA value of VolumeBar to 0', function(assert) { | ||
const player = TestHelpers.makePlayer({ techOrder: ['html5'] }); | ||
const volumeBar = new VolumeBar(player); | ||
const muteToggle = new MuteToggle(player); | ||
|
||
volumeBar.updateARIAAttributes(); | ||
|
||
assert.equal(player.volume(), 1, 'Volume is 1'); | ||
assert.equal(player.muted(), false, 'Muted is false'); | ||
assert.equal(volumeBar.el_.getAttribute('aria-valuenow'), 100, 'ARIA value of VolumeBar is 100'); | ||
|
||
muteToggle.handleClick(); | ||
|
||
volumeBar.updateARIAAttributes(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this still required after the tick update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, see comment below. The last assertion ("ARIA value is 0") fails with that line removed or replaced with another tick update. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably because it's async. One thing that might be more accurate is to trigger a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's better. Have updated. Think there's any way around the async thing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, unless you want to change the QUnit test to be an async test, which is generally frowned upon. This should be fine, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I added a comment explaining the reason for the |
||
|
||
assert.equal(player.volume(), 1, 'Volume remains 1'); | ||
assert.equal(player.muted(), true, 'Muted is true'); | ||
assert.equal(volumeBar.el_.getAttribute('aria-valuenow'), 0, 'ARIA value of VolumeBar is 0'); | ||
}); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about changing this
const
to alet
, and then setting it to0
, ifmuted
is true? That way, we aren't duplicated the setting of thearia-volumenow
andaria-valuetext
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah, that's much better! It occurred to me that perhaps using a conditional could make
updateARIAAttributes
even shorter and also, by extracting the statement that returns volume as a percentage into a named method, eliminate the need for an explanatory comment; please see 0c5f3cc and let me know what you think.