Commit bfece13c authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Setting "" as <track> 'src' should fail the first time

When setting a track .src to "", we would resolve the URL to a null URL,
which matched the default initialized HTMLTrackElement::url_, meaning
that readyState was not advanced and no 'error' event fired in this
case.

Extend the "url == url_" check with a check for readyState differing from
'none'. Also rewrite HTMLTrackElement::getReadyState to avoid using
EnsureTrack().

Bug: 811713
Change-Id: Icd190492639c53e09a7e018202b69ac6e919a94c
Reviewed-on: https://chromium-review.googlesource.com/916004
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarsrirama chandra sekhar <srirama.m@samsung.com>
Cr-Commit-Position: refs/heads/master@{#536685}
parent 5ee2b9b0
<!DOCTYPE html>
<title>Setting HTMLTrackElement.src to the empty string fires 'error' and sets readyState to ERROR</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(t => {
let track = document.createElement("track");
track.src = '';
track.default = true;
track.onerror = t.step_func_done(() => {
assert_equals(track.readyState, HTMLTrackElement.ERROR);
});
track.onload = t.unreached_func('fired load');
assert_equals(track.readyState, HTMLTrackElement.NONE);
document.querySelector('video').appendChild(track);
});
</script>
......@@ -180,7 +180,7 @@ void HTMLTrackElement::LoadTimerFired(TimerBase*) {
// Also we will first check if the new URL is not equal with
// the previous URL (there is an unclarified issue in spec
// about it, see: https://github.com/whatwg/html/issues/2916)
if (url == url_)
if (url == url_ && getReadyState() != kNone)
return;
if (track_)
......@@ -316,7 +316,7 @@ void HTMLTrackElement::SetReadyState(ReadyState state) {
}
HTMLTrackElement::ReadyState HTMLTrackElement::getReadyState() {
return static_cast<ReadyState>(EnsureTrack()->GetReadinessState());
return track_ ? static_cast<ReadyState>(track_->GetReadinessState()) : kNone;
}
const AtomicString& HTMLTrackElement::MediaElementCrossOriginAttribute() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment