Commit 99fa8c15 authored by Sriram's avatar Sriram Committed by Commit Bot

Upstream track-disabled-* and track-element-* tests

Upstream the below tests from media/track/ to wpt
1. track-disabled-addcue.html
2. track-disabled.html
3. track-element-dom-change-crash.html
4. track-element-src-change-error-handling.html
5. track-element-src-change.html

Bug: 782555
Change-Id: I9b4c6a105c8ceae5f8787f511025b2cdaaefc6b9
Reviewed-on: https://chromium-review.googlesource.com/848436Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Commit-Queue: srirama chandra sekhar <srirama.m@samsung.com>
Cr-Commit-Position: refs/heads/master@{#526704}
parent 89a75d27
<!DOCTYPE html>
<title>Test adding cues to a disabled text track. </title>
<script src="../media-file.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<title>Adding cues to a disabled text track</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
var cueDuration = 0.1;
......@@ -17,18 +17,17 @@ async_test(function(t) {
}
// Waiting for 2 cue durations to elapse.
video.ontimeupdate = t.step_func(function(e) {
if (e.target.currentTime < (2 * cueDuration))
video.ontimeupdate = t.step_func(function(event) {
if (event.target.currentTime < (2 * cueDuration))
return;
// End test after at least 2 cueDurations to make sure the test
// doesn't crash during the period the first 2 cues would have been
// rendered if the track was not disabled.
// 2 cue durations have elapsed.
// would have gone through the period where the first 2 cues would
// have been rendered if the track was not disabled.
t.done();
});
video.src = findMediaFile("video", "../content/test");
video.src = getVideoURI("/media/test");
video.play();
});
</script>
\ No newline at end of file
<!DOCTYPE html>
<title>Disabling a track</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track kind="subtitles" src="resources/captions.vtt"/>
</video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.textTracks[0].mode = "disabled";
// Waiting for the duration of the first cue to elapse.
video.ontimeupdate = t.step_func(function (event) {
if (event.target.currentTime < 1)
return;
// End test after the duration of the first cue to make sure
// the test would have gone through the period where this cue
// would have been rendered if the track was not disabled.
t.done();
});
video.src = getVideoURI("/media/test");
video.play();
});
</script>
\ No newline at end of file
<!DOCTYPE html>
<title>Tests that the browser handles simple DOM mutations properly.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<title>Simple DOM mutations with track element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var video = document.createElement("video");
......
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/settings.vtt" default>
<script>
async_test(function(t) {
var cues = null;
var testTrack = document.querySelector("track");
var stage = 0;
var timer = null;
function step_onLoad() {
switch (stage) {
case 0:
cues = testTrack.track.cues;
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
assert_equals(cues.length, 4, "Number of cues after first loading of the track");
++stage;
testTrack.src = "resources/non-existing-file.vtt"; // this should fail
break;
case 1:
case 3:
case 5:
assert_unreached("'error' event did not fire, stage = " + stage);
break;
case 2:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
assert_equals(cues.length, 4, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.src = ""; // this should fail
// CuesList will be cleared in the next tick. Spec claims that this should happen immediately,
// but all implementations are doing this asynchronously.
assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the empty URL");
// This should raise onError event. If no, we'll know about this after some time.
timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
break;
case 4:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
assert_equals(cues.length, 4, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.removeAttribute('src');
// This should raise onError event, so we'll wait for it for some time
timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
break;
default:
assert_unreached("unexpected stage number = " + stage);
break;
}
}
function step_onError() {
switch (stage) {
case 0:
case 2:
case 4:
assert_unreached("'error' event fired, stage = " + stage);
break;
case 1:
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 0, "Number of cues after trying to load non-existing url");
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after trying to load non-existing url");
++stage;
testTrack.src = "resources/settings.vtt";
break;
case 3:
clearTimeout(timer);
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after setting an empty URL");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 0, "Number of cues with an empty URL set");
++stage;
testTrack.src = "resources/settings.vtt";
break;
case 5:
clearTimeout(timer);
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after removing 'src' attr");
assert_equals(cues.length, 0, "Number of cues after removing 'src' attr");
t.done();
break;
default:
assert_unreached("unexpected stage number = " + stage);
break;
}
}
testTrack.onload = t.step_func(step_onLoad);
testTrack.onerror = t.step_func(step_onError);
});
</script>
</video>
\ No newline at end of file
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/settings.vtt" default>
<script>
async_test(function(t) {
var cues = null;
var testTrack = document.querySelector("track");
var stage = 0;
function step_onLoad() {
switch (stage) {
case 0:
cues = testTrack.track.cues;
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
assert_equals(cues.length, 4, "Number of cues after first loading of the track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.src = "resources/entities.vtt";
// CuesList will be cleared in a microtask. Spec claims that this should happen immediately,
// but all known implementations are doing this asynchronously.
assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the new URL");
break;
case 1:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED), "readyState after loading of the second track";
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 7, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'This & is parsed to the same as &amp;.', "Last cue content check");
++stage;
testTrack.src = "resources/settings.vtt";
break;
case 2:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after after loading of the first track again");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 4, "Number of cues after loading of the first track");
++stage;
testTrack.src = "resources/settings.vtt";
// This should not raise onLoad or onError event, so we'll wait for it for some time
t.step_timeout(t.step_func_done(function() {
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after changing 'src' to the same value");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 4, "Number of cues after changing 'src' to the same value");
}, 100));
break;
case 3:
assert_unreached("'load' event should not fire, stage = " + stage);
break;
}
}
testTrack.onload = t.step_func(step_onLoad);
testTrack.onerror = t.unreached_func("'error' event should not fire");
});
</script>
</video>
\ No newline at end of file
WEBVTT
Cue content with escape characters for &, <, >, LRM, RLM and non-breaking space.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
This cue has an ampersand &amp; character.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
This cue has a less than &lt; character.
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
This cue has a greater than &gt; character.
4
00:02:01.000 --> 00:02:30.500 align:start position:20%
This cue has a Left-to-Right Mark &lrm;.
5
00:02:31.000 --> 00:03:00.500 align:start position:20%
This cue has a Right-to-Left Mark &rlm;.
6
00:03:01.000 --> 00:03:30.500 align:start position:20%
This cue has a non-breaking space &nbsp;.
7
00:03:31.000 --> 00:04:00.500
This & is parsed to the same as &amp;.
<!DOCTYPE html>
<title>Test disabling a track.</title>
<video>
<track kind="subtitles" src="captions-webvtt/captions.vtt"/>
</video>
<script src="../media-file.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.textTracks[0].mode = "disabled";
// Waiting for the duration of the first cue to elapse.
video.ontimeupdate = t.step_func(function (e) {
if (e.target.currentTime < 1)
return;
// End test after the duration of the first cue to make sure
// the test doesn't crash during the period this cue would
// have been rendered if the track was not disabled.
// The duration of the first cue has elapsed.
t.done();
});
video.src = findMediaFile("video", "../content/test");
video.play();
});
</script>
\ No newline at end of file
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<video>
<track src="captions-webvtt/tc013-settings.vtt" default>
</video>
<script>
async_test(function(t) {
var cues = null;
var testTrack = document.querySelector("track");
var stage = 0;
var timer = null;
function step_onLoad() {
switch (stage) {
case 0:
cues = testTrack.track.cues;
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
assert_equals(cues.length, 4, "Number of cues after first loading of the track");
++stage;
testTrack.src = "captions-webvtt/non-existing-file.vtt"; // this should fail
break;
case 1:
case 3:
case 5:
assert_unreached("'error' event did not fire, stage = " + stage);
break;
case 2:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
assert_equals(cues.length, 4, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.src = ""; // this should fail
// CuesList will be cleared in the next tick. Spec claims that this should happen immediately,
// but all implementations are doing this asynchronously.
assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the empty URL");
// This should raise onError event. If no, we'll know about this after some time.
timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
break;
case 4:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
assert_equals(cues.length, 4, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.removeAttribute('src');
// This should raise onError event, so we'll wait for it for some time
timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
break;
default:
assert_unreached("unexpected stage number = " + stage);
break;
}
}
function step_onError() {
switch (stage) {
case 0:
case 2:
case 4:
assert_unreached("'error' event fired, stage = " + stage);
break;
case 1:
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 0, "Number of cues after trying to load non-existing url");
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after trying to load non-existing url");
++stage;
testTrack.src = "captions-webvtt/tc013-settings.vtt";
break;
case 3:
clearTimeout(timer);
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after setting an empty URL");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 0, "Number of cues with an empty URL set");
++stage;
testTrack.src = "captions-webvtt/tc013-settings.vtt";
break;
case 5:
clearTimeout(timer);
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after removing 'src' attr");
assert_equals(cues.length, 0, "Number of cues after removing 'src' attr");
t.done();
break;
default:
assert_unreached("unexpected stage number = " + stage);
break;
}
}
testTrack.onload = t.step_func(step_onLoad);
testTrack.onerror = t.step_func(step_onError);
});
</script>
\ No newline at end of file
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<video>
<track src="captions-webvtt/tc013-settings.vtt" default>
</video>
<script>
async_test(function(t) {
var cues = null;
var testTrack = document.querySelector("track");
var stage = 0;
function step_onLoad() {
switch (stage) {
case 0:
cues = testTrack.track.cues;
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
assert_equals(cues.length, 4, "Number of cues after first loading of the track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.src = "captions-webvtt/tc022-entities.vtt";
// CuesList will be cleared in a microtask. Spec claims that this should happen immediately,
// but all known implementations are doing this asynchronously.
assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the new URL");
break;
case 1:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED), "readyState after loading of the second track";
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 7, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'This & is parsed to the same as &amp;.', "Last cue content check");
++stage;
testTrack.src = "captions-webvtt/tc013-settings.vtt";
break;
case 2:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after after loading of the first track again");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 4, "Number of cues after loading of the first track");
++stage;
testTrack.src = "captions-webvtt/tc013-settings.vtt";
// This should not raise onLoad or onError event, so we'll wait for it for some time
t.step_timeout(t.step_func_done(function() {
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after changing 'src' to the same value");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 4, "Number of cues after changing 'src' to the same value");
}, 100));
break;
case 3:
assert_unreached("'load' event should not fire, stage = " + stage);
break;
}
}
testTrack.onload = t.step_func(step_onLoad);
testTrack.onerror = t.unreached_func("'error' event should not fire");
});
</script>
\ No newline at end of file
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