diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webvtt/test/mochitest/test_trackevent.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webvtt/test/mochitest/test_trackevent.html')
-rw-r--r-- | dom/media/webvtt/test/mochitest/test_trackevent.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/media/webvtt/test/mochitest/test_trackevent.html b/dom/media/webvtt/test/mochitest/test_trackevent.html new file mode 100644 index 0000000000..ffba7d33ec --- /dev/null +++ b/dom/media/webvtt/test/mochitest/test_trackevent.html @@ -0,0 +1,69 @@ + +<!DOCTYPE HTML> +<html> +<head> + <title>Test for Bug 893309 - Implement TrackEvent</title> + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> +SimpleTest.waitForExplicitFinish(); + +var video = document.createElement("video"); +isnot(video.textTracks, undefined, "HTMLMediaElement::TextTrack() property should be available.") +ok(typeof video.addTextTrack == "function", "HTMLMediaElement::AddTextTrack() function should be available.") + +var trackList = video.textTracks; +is(trackList.length, 0, "Length should be 0."); + +var evtTextTrack, numOfCalls = 0, tt; +trackList.onaddtrack = function(event) { + ok(event instanceof TrackEvent, "Fired event from onaddtrack should be a TrackEvent"); + is(event.type, "addtrack", "Event type should be addtrack"); + ok(event.isTrusted, "Event should be trusted!"); + ok(!event.bubbles, "Event shouldn't bubble!"); + ok(!event.cancelable, "Event shouldn't be cancelable!"); + + evtTextTrack = event.track; + tt = textTrack[numOfCalls].track || textTrack[numOfCalls]; + + ok(tt === evtTextTrack, "Text tracks should be the same"); + is(evtTextTrack.label, label[numOfCalls], "Label should be set to "+ label[numOfCalls]); + is(evtTextTrack.language, language[numOfCalls], "Language should be " + language[numOfCalls]); + is(evtTextTrack.kind, kind[numOfCalls], "Kind should be " + kind[numOfCalls]); + + if (++numOfCalls == 4) { + SimpleTest.finish(); + } +}; + +var label = ["Oasis", "Coldplay", "t.A.T.u", ""]; +var language = ["en-CA", "en-GB", "ru", ""]; +var kind = ["subtitles", "captions", "chapters", "subtitles"]; + +var textTrack = new Array(4); +for (var i = 0; i < 3; ++i) { + textTrack[i] = video.addTextTrack(kind[i], label[i], language[i]); + is(trackList.length, i + 1, "Length should be " + (i+1)); +} + +video.src = "seek.webm"; +video.preload = "auto"; +var trackElement = document.createElement("track"); +trackElement.src = "basic.vtt"; +textTrack[3] = trackElement; + +document.getElementById("content").appendChild(video); +video.appendChild(trackElement); + +//TODO: Tests for removetrack event to be added along with bug 882677 +</script> +</pre> +</body> +</html> |