diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/content/tests/widgets/test_videocontrols_vtt.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/content/tests/widgets/test_videocontrols_vtt.html')
-rw-r--r-- | toolkit/content/tests/widgets/test_videocontrols_vtt.html | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/toolkit/content/tests/widgets/test_videocontrols_vtt.html b/toolkit/content/tests/widgets/test_videocontrols_vtt.html new file mode 100644 index 000000000..27052b770 --- /dev/null +++ b/toolkit/content/tests/widgets/test_videocontrols_vtt.html @@ -0,0 +1,133 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Video controls test - VTT</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> + +<div id="content"> + <video id="video" controls preload="auto"></video> +</div> + +<pre id="test"> +<script clas="testbody" type="application/javascript"> + SimpleTest.waitForExplicitFinish(); + + const domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]. + getService(SpecialPowers.Ci.inIDOMUtils); + const video = document.getElementById("video"); + const ccBtn = getElementByAttribute("class", "closedCaptionButton"); + const ttList = getElementByAttribute("class", "textTrackList"); + const testCases = []; + + testCases.push(() => new Promise(resolve => { + is(ccBtn.getAttribute("hidden"), "true", "CC button should hide"); + + resolve(); + })); + + testCases.push(() => new Promise(resolve => { + video.addTextTrack("descriptions", "English", "en"); + video.addTextTrack("chapters", "English", "en"); + video.addTextTrack("metadata", "English", "en"); + + SimpleTest.executeSoon(() => { + is(ccBtn.getAttribute("hidden"), "true", "CC button should hide if no supported tracks provided"); + + resolve(); + }); + })); + + testCases.push(() => new Promise(resolve => { + const sub = video.addTextTrack("subtitles", "English", "en"); + sub.mode = "disabled"; + + SimpleTest.executeSoon(() => { + is(ccBtn.getAttribute("hidden"), "", "CC button should show"); + is(ccBtn.getAttribute("enabled"), "", "CC button should be disabled"); + + resolve(); + }); + })); + + testCases.push(() => new Promise(resolve => { + const subtitle = video.addTextTrack("subtitles", "English", "en"); + subtitle.mode = "showing"; + + SimpleTest.executeSoon(() => { + is(ccBtn.getAttribute("enabled"), "true", "CC button should be enabled"); + subtitle.mode = "disabled"; + + resolve(); + }); + })); + + testCases.push(() => new Promise(resolve => { + const caption = video.addTextTrack("captions", "English", "en"); + caption.mode = "showing"; + + SimpleTest.executeSoon(() => { + is(ccBtn.getAttribute("enabled"), "true", "CC button should be enabled"); + + resolve(); + }); + })); + + testCases.push(() => new Promise(resolve => { + synthesizeMouseAtCenter(ccBtn, {}); + + SimpleTest.executeSoon(() => { + is(ttList.hasAttribute("hidden"), false, "Texttrack menu should show up"); + is(ttList.lastChild.getAttribute("on"), "true", "The last added item should be highlighted"); + + resolve(); + }); + })); + + testCases.push(() => new Promise(resolve => { + const tt = ttList.children[1]; + + isnot(tt.getAttribute("on"), "true", "Item should be off before click"); + synthesizeMouseAtCenter(tt, {}); + + SimpleTest.executeSoon(() => { + is(tt.getAttribute("on"), "true", "Selected item should be enabled"); + is(ttList.getAttribute("hidden"), "true", "Should hide texttrack menu once clicked on an item"); + + resolve(); + }); + })); + + function executeTestCases(tasks) { + return tasks.reduce((promise, task) => promise.then(task), Promise.resolve()); + } + + function getElementByAttribute(aName, aValue) { + const videoControl = domUtils.getChildrenForNode(video, true)[1]; + + return SpecialPowers.wrap(document) + .getAnonymousElementByAttribute(videoControl, aName, aValue); + } + + function loadedmetadata() { + executeTestCases(testCases).then(SimpleTest.finish); + } + + function startMediaLoad() { + video.src = "seek_with_sound.ogg"; + video.addEventListener("loadedmetadata", loadedmetadata, false); + } + + function loadevent() { + SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, startMediaLoad); + } + + window.addEventListener("load", loadevent, false); +</script> +</pre> +</body> +</html> |