1 <!-- Used by media_seek_perf to record seek perf metrics. -->
5 <title>CNS Seek Tests</title>
6 <script src="utils.js" type="text/javascript"></script>
10 <video controls></video>
14 <script type="text/javascript">
15 var video = document.querySelector("video");
16 var logDiv = document.querySelector("div");
30 logDiv.innerText += text + "\n";
33 function resetSeekRecords() {
35 for (cache_index in Object.keys(CachedState)) {
36 seekRecords[cache_index] = [];
37 for (seek_index in Object.keys(SeekTestCase)) {
38 seekRecords[cache_index][seek_index] = [];
43 // Called by the PyAuto controller to initiate testing.
44 function startTest(src) {
45 if (window.domAutomationController)
46 window.domAutomationController.send(true);
53 video.addEventListener("playing", playing);
54 video.addEventListener("seeked", seeked);
55 video.addEventListener("error", error);
57 log("Running tests on " + originalSrc);
58 log("Starting seek tests without browser caching:");
59 cacheState = CachedState.UNCACHED;
64 function IterationTest() {
65 if (iteration < ITERATIONS) {
67 log("Test iteration " + iteration);
68 seekState = SeekTestCase.SHORT;
69 video.src = getVideoSrc();
71 } else if (cacheState == CachedState.UNCACHED) {
72 log("Starting seek tests with browser caching:");
73 cacheState = CachedState.CACHED;
81 function getVideoSrc() {
82 if (cacheState == CachedState.UNCACHED) {
83 return GenerateUniqueURL(originalSrc);
90 if (seekState == SeekTestCase.SHORT) {
92 video.currentTime = 1;
99 case SeekTestCase.SHORT:
100 seekRecords[cacheState][SeekTestCase.SHORT].push(delta);
101 log ("short seek in " + delta + "ms.")
102 seekState = SeekTestCase.LONG;
104 video.currentTime = video.duration - 1;
106 // Seek to almost end of file (unbuffered area).
107 case SeekTestCase.LONG:
108 seekRecords[cacheState][SeekTestCase.LONG].push(delta);
109 log("long seek in " + delta + "ms.")
113 end("An un-expected seek occured.");
123 function error(evt) {
124 end("Error loading media: " + evt.target + " " + evt.type + " " +