Bug 1550633 - part13.3 - create elements in HTML, not in JS. r=jya

Create test elements in HTML beforehand, which can remove unnecessary JS code and make test cleaner.

Differential Revision: https://phabricator.services.mozilla.com/D31911

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2019-05-24 00:41:08 +00:00
Родитель 75459f89eb
Коммит 4b62a057ad
7 изменённых файлов: 28 добавлений и 62 удалений

Просмотреть файл

@ -6,21 +6,15 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="metadata">
<track src="bug883173.vtt" kind="subtitles" id="default" default>
</video>
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var video = document.createElement("video");
video.src = "seek.webm";
video.preload = "metadata";
var trackElement = document.createElement("track");
trackElement.src = "bug883173.vtt";
trackElement.kind = "subtitles";
document.appendChild(video);
video.appendChild(trackElement);
let video = document.getElementById("v");
video.addEventListener("loadedmetadata",
function run_tests() {
let trackElement = document.getElementById("default");
// Re-queue run_tests() at the end of the event loop until the track
// element has loaded its data.
if (trackElement.readyState == 1) {

Просмотреть файл

@ -6,26 +6,16 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="metadata">
<track src="long.vtt" kind="subtitles" id="track1">
<track src="long.vtt" kind="subtitles" id="track2">
</video>
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var video = document.createElement("video");
video.src = "seek.webm";
video.preload = "metadata";
var trackElement = document.createElement("track");
trackElement.src = "long.vtt";
trackElement.kind = "subtitles";
var trackElementTwo = document.createElement("track");
trackElementTwo.src = "long.vtt";
trackElementTwo.kind = "subtitles";
document.appendChild(video);
video.appendChild(trackElement);
video.appendChild(trackElementTwo);
let video = document.getElementById("v");
video.addEventListener("loadedmetadata", function run_tests() {
let trackElement = document.getElementById("track1");
let trackElementTwo = document.getElementById("track2");
// Re-que run_tests() at the end of the event loop until the track
// element has loaded its data.
if (trackElement.readyState == 1 || trackElementTwo.readyState == 1) {

Просмотреть файл

@ -6,10 +6,11 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v">
<script type="text/javascript">
function runTest() {
var video = document.createElement("video");
var video = document.getElementById("v");
isnot(video.textTracks, undefined, "HTMLMediaElement::TextTrack() property should be available.")
@ -70,8 +71,6 @@ function runTest() {
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.

Просмотреть файл

@ -6,10 +6,11 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="metadata">
<script type="text/javascript">
function runTest() {
var video = document.createElement("video");
var video = document.getElementById("v");
// Check if adding a text track manually sets the TextTrackList correctly.
@ -21,18 +22,11 @@ function runTest() {
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";
var trackElement = document.createElement("track");
trackElement.src = "basic.vtt";
trackElement.kind = "subtitles";
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.

Просмотреть файл

@ -6,20 +6,16 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="metadata">
<track src="basic.vtt" kind="subtitles" id="default" default>
</video>
<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 = "metadata";
var video = document.getElementById("v");
var trackElement = document.getElementById("default");
var trackElement = document.createElement("track");
trackElement.src = "basic.vtt";
trackElement.kind = "subtitles";
document.appendChild(video);
video.appendChild(trackElement);
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.

Просмотреть файл

@ -6,20 +6,15 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="auto">
<track src="region.vtt" kind="subtitles" id="default" default>
</video>
<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 trackElement = document.createElement("track");
trackElement.src = "region.vtt";
trackElement.kind = "subtitles";
document.appendChild(video);
video.appendChild(trackElement);
var video = document.getElementById("v");
var trackElement = document.getElementById("default");
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.

Просмотреть файл

@ -6,12 +6,11 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="auto">
<script type="text/javascript">
function runTest() {
var video = document.createElement("video");
video.src = "seek.webm";
video.preload = "auto";
var video = document.getElementById("v");
var trackOne = document.createElement("track");
trackOne.src = "basic.vtt";
@ -50,7 +49,6 @@ function runTest() {
trackThree.addEventListener("load", shouldNotBeCalled);
trackThree.addEventListener("error", trackThreeEvent);
document.appendChild(video);
video.appendChild(trackOne);
video.appendChild(trackTwo);
video.appendChild(trackThree);