Skip to content

Commit

Permalink
Update playbackRate tests to check for behavior when set to an unsupp…
Browse files Browse the repository at this point in the history
…orted value

See whatwg/html#2829 for HTML Standard change.
  • Loading branch information
japacible authored and annevk committed Jul 19, 2017
1 parent f2dfb90 commit a5c429f
Showing 1 changed file with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,46 @@
assert_equals(v.playbackRate, 1);
}, 'playbackRate initial value');

async_test(function(t) {
function testPlaybackRateHelper(t, newPlaybackRate) {
var v = document.createElement('video');
v.playbackRate = 2;
v.addEventListener('ratechange', t.step_func(function() {
var initialRate = v.playbackRate;

v.addEventListener('ratechange', function() {
assert_equals(v.playbackRate, newPlaybackRate);
t.done();
}));
}, 'setting playbackRate');
});

try {
v.playbackRate = newPlaybackRate;
} catch(e) {
assert_equals(e.name, 'NotSupportedError');
assert_equals(v.playbackRate, initialRate);
t.done();
}
}

async_test(function(t) {
testPlaybackRateHelper(this, 3);
}, "playbackRate set to small positive value");

async_test(function(t) {
testPlaybackRateHelper(this, 100);
}, "playbackRate set to large positive value");

async_test(function(t) {
testPlaybackRateHelper(this, -3);
}, "playbackRate set to small negative value");

async_test(function(t) {
testPlaybackRateHelper(this, -100);
}, "playbackRate set to large negative value");

async_test(function(t) {
testPlaybackRateHelper(this, 0);
}, "playbackRate set to 0");

async_test(function(t) {
testPlaybackRateHelper(this, -1);
}, "playbackRate set to -1");

</script>

0 comments on commit a5c429f

Please sign in to comment.