зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550633 - part13.2 - no need to set pref "media.webvtt.regions.enabled". r=jya
These tests didn't use region at all, so we have no need to set the pref. Differential Revision: https://phabricator.services.mozilla.com/D31910 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
35f5a82cdc
Коммит
75459f89eb
|
@ -7,110 +7,113 @@
|
|||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.webvtt.regions.enabled", true]]},
|
||||
function() {
|
||||
var video = document.createElement("video");
|
||||
|
||||
isnot(video.textTracks, undefined, "HTMLMediaElement::TextTrack() property should be available.")
|
||||
function runTest() {
|
||||
var video = document.createElement("video");
|
||||
|
||||
var trackList = video.textTracks;
|
||||
is(trackList.length, 0, "Length should be 0.");
|
||||
isnot(video.textTracks, undefined, "HTMLMediaElement::TextTrack() property should be available.")
|
||||
|
||||
ok(typeof video.addTextTrack == "function", "HTMLMediaElement::AddTextTrack() function should be available.")
|
||||
video.addTextTrack("subtitles", "third", "en-CA");
|
||||
is(trackList.length, 1, "Length should be 1.");
|
||||
var trackList = video.textTracks;
|
||||
is(trackList.length, 0, "Length should be 0.");
|
||||
|
||||
var textTrack = video.textTracks[0];
|
||||
is(textTrack.label, "third", "Label should be set to third.");
|
||||
is(textTrack.language, "en-CA", "Language should be en-CA.");
|
||||
is(textTrack.kind, "subtitles", "Default kind should be subtitles.");
|
||||
is(textTrack.mode, "hidden", "Default mode should be hidden.");
|
||||
ok(typeof video.addTextTrack == "function", "HTMLMediaElement::AddTextTrack() function should be available.")
|
||||
video.addTextTrack("subtitles", "third", "en-CA");
|
||||
is(trackList.length, 1, "Length should be 1.");
|
||||
|
||||
// Mode should not allow a bogus value.
|
||||
textTrack.mode = 'bogus';
|
||||
is(textTrack.mode, 'hidden', "Mode should be not allow a bogus value.");
|
||||
var textTrack = video.textTracks[0];
|
||||
is(textTrack.label, "third", "Label should be set to third.");
|
||||
is(textTrack.language, "en-CA", "Language should be en-CA.");
|
||||
is(textTrack.kind, "subtitles", "Default kind should be subtitles.");
|
||||
is(textTrack.mode, "hidden", "Default mode should be hidden.");
|
||||
|
||||
// Should allow all these values for mode.
|
||||
checkMode("showing", "Mode should allow \"showing\"");
|
||||
checkMode("disabled", "Mode should allow \"disabled\"");
|
||||
checkMode("hidden", "Mode should allow \"hidden\"");
|
||||
// Mode should not allow a bogus value.
|
||||
textTrack.mode = 'bogus';
|
||||
is(textTrack.mode, 'hidden', "Mode should be not allow a bogus value.");
|
||||
|
||||
// All below are read-only properties and so should not allow setting.
|
||||
textTrack.label = "French subtitles";
|
||||
is(textTrack.label, "third", "Label is read-only so should still be \"label\".");
|
||||
// Should allow all these values for mode.
|
||||
checkMode("showing", "Mode should allow \"showing\"");
|
||||
checkMode("disabled", "Mode should allow \"disabled\"");
|
||||
checkMode("hidden", "Mode should allow \"hidden\"");
|
||||
|
||||
textTrack.language = "en";
|
||||
is(textTrack.language, "en-CA", "Language is read-only so should still be \"en-CA\".");
|
||||
// All below are read-only properties and so should not allow setting.
|
||||
textTrack.label = "French subtitles";
|
||||
is(textTrack.label, "third", "Label is read-only so should still be \"label\".");
|
||||
|
||||
textTrack.kind = "captions";
|
||||
is(textTrack.kind, "subtitles", "Kind is read-only so should still be \"subtitles\"");
|
||||
textTrack.language = "en";
|
||||
is(textTrack.language, "en-CA", "Language is read-only so should still be \"en-CA\".");
|
||||
|
||||
function checkMode(value, message) {
|
||||
textTrack.mode = value;
|
||||
is(textTrack.mode, value, message);
|
||||
textTrack.kind = "captions";
|
||||
is(textTrack.kind, "subtitles", "Kind is read-only so should still be \"subtitles\"");
|
||||
|
||||
function checkMode(value, message) {
|
||||
textTrack.mode = value;
|
||||
is(textTrack.mode, value, message);
|
||||
}
|
||||
|
||||
// Insert some tracks in an order that is not sorted, we will test if they
|
||||
// are sorted later.
|
||||
var trackOne = document.createElement("track");
|
||||
trackOne.label = "first";
|
||||
trackOne.src = "basic.vtt";
|
||||
trackOne.default = true;
|
||||
trackOne.id = "2";
|
||||
video.appendChild(trackOne);
|
||||
|
||||
video.addTextTrack("subtitles", "fourth", "en-CA");
|
||||
|
||||
var trackTwo = document.createElement("track");
|
||||
trackTwo.label = "second";
|
||||
trackTwo.src = "basic.vtt";
|
||||
trackTwo.default = true;
|
||||
video.appendChild(trackTwo);
|
||||
|
||||
video.src = "seek.webm";
|
||||
video.preload = "metadata";
|
||||
|
||||
document.appendChild(video);
|
||||
|
||||
video.addEventListener("loadedmetadata", function run_tests() {
|
||||
// Re-que run_tests() at the end of the event loop until the track
|
||||
// element has loaded its data.
|
||||
if (trackOne.readyState == 1 || trackTwo.readyState == 1) {
|
||||
setTimeout(run_tests, 0);
|
||||
return;
|
||||
}
|
||||
is(trackOne.readyState, 2, "First Track::ReadyState should be set to LOADED.");
|
||||
is(trackTwo.readyState, 2, "Second Track::ReadyState should be set to LOADED.");
|
||||
|
||||
// Insert some tracks in an order that is not sorted, we will test if they
|
||||
// are sorted later.
|
||||
var trackOne = document.createElement("track");
|
||||
trackOne.label = "first";
|
||||
trackOne.src = "basic.vtt";
|
||||
trackOne.default = true;
|
||||
trackOne.id = "2";
|
||||
video.appendChild(trackOne);
|
||||
|
||||
video.addTextTrack("subtitles", "fourth", "en-CA");
|
||||
|
||||
var trackTwo = document.createElement("track");
|
||||
trackTwo.label = "second";
|
||||
trackTwo.src = "basic.vtt";
|
||||
trackTwo.default = true;
|
||||
video.appendChild(trackTwo);
|
||||
|
||||
video.src = "seek.webm";
|
||||
video.preload = "metadata";
|
||||
|
||||
document.appendChild(video);
|
||||
|
||||
video.addEventListener("loadedmetadata", function run_tests() {
|
||||
// Re-que run_tests() at the end of the event loop until the track
|
||||
// element has loaded its data.
|
||||
if (trackOne.readyState == 1 || trackTwo.readyState == 1) {
|
||||
setTimeout(run_tests, 0);
|
||||
return;
|
||||
// We're testing two things here, firstly that tracks created from a track
|
||||
// element have a default mode 'disabled' and tracks created with the
|
||||
// 'addTextTrack' method have a default mode of 'hidden'.
|
||||
// Secondly we're testing that the tracks are sorted properly.
|
||||
// For the tracks to be sorted the first two tracks, added through a
|
||||
// TrackElement, must occupy the first two indexes in their TrackElement
|
||||
// tree order. The second two tracks, added through the 'addTextTrack'
|
||||
// method, will occupy the last two indexes in the order that they were
|
||||
// added in.
|
||||
var trackData = [
|
||||
{ label: "first", mode: "showing", id: "2" },
|
||||
{ label: "second", mode: "disabled", id: "" },
|
||||
{ label: "third", mode: "hidden", id: "" },
|
||||
{ label: "fourth", mode: "hidden", id: "" }
|
||||
];
|
||||
is(video.textTracks.length, trackData.length, "TextTracks length should be " + trackData.length);
|
||||
for (var i = 0; i < trackData.length; i++) {
|
||||
var track = video.textTracks[i];
|
||||
isnot(track, null, "Video should have a text track at index " + i);
|
||||
var info = trackData[i];
|
||||
for (var key in info) {
|
||||
is(track[key], info[key], "Track at index " + i + " should have a '" + key + "'' property " +
|
||||
"with a value of '" + info[key] + "'.");
|
||||
}
|
||||
is(trackOne.readyState, 2, "First Track::ReadyState should be set to LOADED.");
|
||||
is(trackTwo.readyState, 2, "Second Track::ReadyState should be set to LOADED.");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = runTest;
|
||||
|
||||
// We're testing two things here, firstly that tracks created from a track
|
||||
// element have a default mode 'disabled' and tracks created with the
|
||||
// 'addTextTrack' method have a default mode of 'hidden'.
|
||||
// Secondly we're testing that the tracks are sorted properly.
|
||||
// For the tracks to be sorted the first two tracks, added through a
|
||||
// TrackElement, must occupy the first two indexes in their TrackElement
|
||||
// tree order. The second two tracks, added through the 'addTextTrack'
|
||||
// method, will occupy the last two indexes in the order that they were
|
||||
// added in.
|
||||
var trackData = [
|
||||
{ label: "first", mode: "showing", id: "2" },
|
||||
{ label: "second", mode: "disabled", id: "" },
|
||||
{ label: "third", mode: "hidden", id: "" },
|
||||
{ label: "fourth", mode: "hidden", id: "" }
|
||||
];
|
||||
is(video.textTracks.length, trackData.length, "TextTracks length should be " + trackData.length);
|
||||
for (var i = 0; i < trackData.length; i++) {
|
||||
var track = video.textTracks[i];
|
||||
isnot(track, null, "Video should have a text track at index " + i);
|
||||
var info = trackData[i];
|
||||
for (var key in info) {
|
||||
is(track[key], info[key], "Track at index " + i + " should have a '" + key + "'' property " +
|
||||
"with a value of '" + info[key] + "'.");
|
||||
}
|
||||
}
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,50 +7,52 @@
|
|||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.webvtt.regions.enabled", true]]},
|
||||
function() {
|
||||
var video = document.createElement("video");
|
||||
|
||||
// Check if adding a text track manually sets the TextTrackList correctly.
|
||||
function runTest() {
|
||||
var video = document.createElement("video");
|
||||
|
||||
// HTMLTrackElement.textTrackList is an extension available only to
|
||||
// privileged code, so we need to access it through the SpecialPowers
|
||||
// object.
|
||||
video.addTextTrack("subtitles", "", "");
|
||||
is(SpecialPowers.unwrap(SpecialPowers.wrap(video.textTracks[0]).textTrackList),
|
||||
video.textTracks,
|
||||
"The Track's TextTrackList should be the Video's TextTrackList.");
|
||||
// Check if adding a text track manually sets the TextTrackList correctly.
|
||||
|
||||
// HTMLTrackElement.textTrackList is an extension available only to
|
||||
// privileged code, so we need to access it through the SpecialPowers
|
||||
// object.
|
||||
video.addTextTrack("subtitles", "", "");
|
||||
is(SpecialPowers.unwrap(SpecialPowers.wrap(video.textTracks[0]).textTrackList),
|
||||
video.textTracks,
|
||||
"The Track's TextTrackList should be the Video's TextTrackList.");
|
||||
|
||||
|
||||
// Check if loading a Track via a TrackElement sets the TextTrackList correctly.
|
||||
video.src = "seek.webm";
|
||||
video.preload = "auto";
|
||||
// Check if loading a Track via a TrackElement sets the TextTrackList correctly.
|
||||
video.src = "seek.webm";
|
||||
video.preload = "auto";
|
||||
|
||||
var trackElement = document.createElement("track");
|
||||
trackElement.src = "basic.vtt";
|
||||
trackElement.kind = "subtitles";
|
||||
var trackElement = document.createElement("track");
|
||||
trackElement.src = "basic.vtt";
|
||||
trackElement.kind = "subtitles";
|
||||
|
||||
video.appendChild(trackElement);
|
||||
document.appendChild(video);
|
||||
video.appendChild(trackElement);
|
||||
document.appendChild(video);
|
||||
|
||||
video.addEventListener("loadedmetadata", function run_tests() {
|
||||
// Re-que run_tests() at the end of the event loop until the track
|
||||
// element has loaded its data.
|
||||
if (trackElement.readyState == HTMLTrackElement.LOADING) {
|
||||
setTimeout(run_tests, 0);
|
||||
return;
|
||||
}
|
||||
is(trackElement.readyState, HTMLTrackElement.LOADED,
|
||||
"Track::ReadyState should be set to LOADED.");
|
||||
is(SpecialPowers.unwrap(SpecialPowers.wrap(trackElement.track).textTrackList),
|
||||
video.textTracks,
|
||||
"TrackElement's Track's TextTrackList should be the Video's TextTrackList.");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
video.addEventListener("loadedmetadata", function run_tests() {
|
||||
// Re-que run_tests() at the end of the event loop until the track
|
||||
// element has loaded its data.
|
||||
if (trackElement.readyState == HTMLTrackElement.LOADING) {
|
||||
setTimeout(run_tests, 0);
|
||||
return;
|
||||
}
|
||||
);
|
||||
is(trackElement.readyState, HTMLTrackElement.LOADED,
|
||||
"Track::ReadyState should be set to LOADED.");
|
||||
is(SpecialPowers.unwrap(SpecialPowers.wrap(trackElement.track).textTrackList),
|
||||
video.textTracks,
|
||||
"TrackElement's Track's TextTrackList should be the Video's TextTrackList.");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = runTest;
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,56 +7,58 @@
|
|||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.webvtt.regions.enabled", true]]},
|
||||
function() {
|
||||
var video = document.createElement("video");
|
||||
video.src = "seek.webm";
|
||||
video.preload = "auto";
|
||||
|
||||
var trackOne = document.createElement("track");
|
||||
trackOne.src = "basic.vtt";
|
||||
trackOne.kind = "subtitles";
|
||||
function runTest() {
|
||||
var video = document.createElement("video");
|
||||
video.src = "seek.webm";
|
||||
video.preload = "auto";
|
||||
|
||||
var trackTwo = document.createElement("track");
|
||||
trackTwo.src = "bad-signature.vtt";
|
||||
trackTwo.kind = "captions";
|
||||
var trackOne = document.createElement("track");
|
||||
trackOne.src = "basic.vtt";
|
||||
trackOne.kind = "subtitles";
|
||||
|
||||
var trackThree = document.createElement("track");
|
||||
trackThree.src = "bad.vtt";
|
||||
trackThree.kind = "chapters";
|
||||
var trackTwo = document.createElement("track");
|
||||
trackTwo.src = "bad-signature.vtt";
|
||||
trackTwo.kind = "captions";
|
||||
|
||||
var events = 0;
|
||||
function trackOneEvent() {
|
||||
ok(true, "A load event for trackOne should have happened.");
|
||||
events++ && events == 3 && SimpleTest.finish();
|
||||
}
|
||||
function trackTwoEvent() {
|
||||
ok(true, "An error event for trackTwo should have happened.");
|
||||
events++ && events == 3 && SimpleTest.finish();
|
||||
}
|
||||
function trackThreeEvent() {
|
||||
ok(true, "An error event for trackThree should have happened.");
|
||||
events++ && events == 3 && SimpleTest.finish();
|
||||
}
|
||||
var trackThree = document.createElement("track");
|
||||
trackThree.src = "bad.vtt";
|
||||
trackThree.kind = "chapters";
|
||||
|
||||
function shouldNotBeCalled() {
|
||||
ok(false, "Event should not have been called.");
|
||||
}
|
||||
|
||||
trackOne.addEventListener("load", trackOneEvent);
|
||||
trackOne.addEventListener("error", shouldNotBeCalled)
|
||||
trackTwo.addEventListener("load", shouldNotBeCalled);
|
||||
trackTwo.addEventListener("error", trackTwoEvent);
|
||||
trackThree.addEventListener("load", shouldNotBeCalled);
|
||||
trackThree.addEventListener("error", trackThreeEvent);
|
||||
|
||||
document.appendChild(video);
|
||||
video.appendChild(trackOne);
|
||||
video.appendChild(trackTwo);
|
||||
video.appendChild(trackThree);
|
||||
var events = 0;
|
||||
function trackOneEvent() {
|
||||
ok(true, "A load event for trackOne should have happened.");
|
||||
events++ && events == 3 && SimpleTest.finish();
|
||||
}
|
||||
);
|
||||
function trackTwoEvent() {
|
||||
ok(true, "An error event for trackTwo should have happened.");
|
||||
events++ && events == 3 && SimpleTest.finish();
|
||||
}
|
||||
function trackThreeEvent() {
|
||||
ok(true, "An error event for trackThree should have happened.");
|
||||
events++ && events == 3 && SimpleTest.finish();
|
||||
}
|
||||
|
||||
function shouldNotBeCalled() {
|
||||
ok(false, "Event should not have been called.");
|
||||
}
|
||||
|
||||
trackOne.addEventListener("load", trackOneEvent);
|
||||
trackOne.addEventListener("error", shouldNotBeCalled)
|
||||
trackTwo.addEventListener("load", shouldNotBeCalled);
|
||||
trackTwo.addEventListener("error", trackTwoEvent);
|
||||
trackThree.addEventListener("load", shouldNotBeCalled);
|
||||
trackThree.addEventListener("error", trackThreeEvent);
|
||||
|
||||
document.appendChild(video);
|
||||
video.appendChild(trackOne);
|
||||
video.appendChild(trackTwo);
|
||||
video.appendChild(trackThree);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = runTest;
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче