| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| |
| <script src=../media-file.js></script> |
| <script src=../video-test.js></script> |
| <script src=../media-controls.js></script> |
| |
| <script> |
| |
| var testTrack; |
| var testCueDisplayBox; |
| var seekedCount = 0; |
| var resizeCount = 1; |
| var info = [ "Lorem", "ipsum", "dolor", "sit" ]; |
| |
| function setVideoSize(width, height) |
| { |
| run("video.width = " + width); |
| run("video.height = " + height); |
| } |
| |
| function resizeTest() |
| { |
| document.body.offsetTop; |
| currentCue = textTrackDisplayElement(video, 'cue'); |
| testExpected("getComputedStyle(currentCue).fontSize", parseInt(240 * resizeCount * 0.05) + "px"); |
| consoleWrite(""); |
| |
| if (++resizeCount < 5) { |
| setVideoSize(320 * resizeCount, 240 * resizeCount); |
| setTimeout(resizeTest, 10); |
| return |
| } |
| |
| testExpected("getComputedStyle(currentCue).fontFamily", "sans-serif"); |
| testExpected("getComputedStyle(currentCue).color", "rgb(255, 255, 255)"); |
| testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.8)"); |
| |
| consoleWrite(""); |
| endTest(); |
| |
| // Resize the video so it is easier to interact with it manually, if necessary. |
| video.width = 320; |
| video.height = 240; |
| } |
| |
| function testCueStyle() |
| { |
| consoleWrite("<br>Test the cue display colors and font."); |
| setVideoSize(320, 240); |
| setTimeout(resizeTest, 10); |
| } |
| |
| function seeked() |
| { |
| if (testEnded) |
| return; |
| |
| testExpected("video.currentTime", seekedCount + .5); |
| testExpected("testTrack.track.activeCues.length", 1); |
| testExpected("testTrack.track.activeCues[0].text", info[seekedCount]); |
| |
| testCueDisplayBox = textTrackDisplayElement(video, 'display'); |
| testExpected("testCueDisplayBox.innerText", info[seekedCount]); |
| testExpected("2 * testCueDisplayBox.offsetLeft == video.videoWidth - testCueDisplayBox.offsetWidth", true) |
| |
| if (++seekedCount == info.length) |
| testCueStyle(); |
| else { |
| consoleWrite(""); |
| run("video.currentTime = " + (video.currentTime + 1)); |
| return; |
| } |
| } |
| |
| function loaded() |
| { |
| consoleWrite("Test that default positioned TextTrack's cues are rendered correctly."); |
| findMediaElement(); |
| testTrack = document.querySelector('track'); |
| video.src = findMediaFile('video', '../content/test'); |
| waitForEvent('seeked', seeked); |
| waitForEvent('canplaythrough', function() { video.currentTime = .5; }); |
| } |
| |
| setCaptionDisplayMode('Automatic'); |
| </script> |
| </head> |
| <body onload="loaded()"> |
| <video controls > |
| <track src="captions-webvtt/captions.vtt" kind="captions" default> |
| </video> |
| </body> |
| </html> |