Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Tests that the video is paused after cues that have pause-on-exit flag ar e processed.</title> |
| 3 <head> | 3 <script src="../../resources/testharness.js"></script> |
| 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="../media-file.js"></script> | |
| 6 <video controls> | |
| 7 <track src="captions-webvtt/simple-captions.vtt" default> | |
| 8 </video> | |
| 9 <script> | |
| 10 async_test(function(t) { | |
| 11 var video = document.querySelector("video"); | |
| 12 video.src = findMediaFile("video", "../content/test"); | |
| 13 video.oncanplaythrough = t.step_func(function() { | |
| 14 video.oncanplaythrough = null; | |
| 15 video.currentTime = 4.00; | |
| 16 runTests(); | |
| 17 }); | |
| 5 | 18 |
| 6 <script src=../media-file.js></script> | 19 var track = document.querySelector("track"); |
| 7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 20 track.onload = t.step_func(runTests); |
|
fs
2016/06/13 15:20:18
See comment on the later test about sequencing.
Srirama
2016/06/13 17:33:38
Done. Removed 'canplaythrough' event, please see m
| |
| 8 (Please avoid writing new tests using video-test.js) --> | |
| 9 <script src=../video-test.js></script> | |
| 10 <script> | |
| 11 var videoCanPlayThrough = false; | |
| 12 var trackLoaded = false; | |
| 13 | 21 |
| 14 var currentCue; | 22 var eventCount = 0; |
| 15 var currentCueNumber = 0; | 23 function runTests() { |
| 24 eventCount++; | |
| 25 if (eventCount != 2) | |
| 26 return; | |
| 16 | 27 |
| 17 function runTests() | 28 assert_equals(track.track.cues.length, 4); |
| 18 { | |
| 19 if (!trackLoaded || !videoCanPlayThrough) | |
| 20 return; | |
| 21 | 29 |
| 22 testTrack = document.getElementById("testTrack"); | 30 for (var i = 0; i < track.track.cues.length; ++i) { |
| 23 testExpected("testTrack.track.cues.length", 4); | 31 track.track.cues[i].pauseOnExit = (i % 2 == 0); |
| 32 } | |
| 24 | 33 |
| 25 consoleWrite(""); | 34 video.play(); |
| 35 assert_false(video.paused); | |
| 36 } | |
| 26 | 37 |
| 27 for (var i = 0; i < testTrack.track.cues.length; ++i) { | 38 var currentCueNumber = 0; |
| 28 testTrack.track.cues[i].pauseOnExit = (i % 2 == 0); | 39 video.onpause = t.step_func(function() { |
| 29 } | 40 track.track.cues[currentCueNumber].onexit = t.step_func(function(event) { |
|
fs
2016/06/13 15:20:18
Maybe these could be installed right after the tra
| |
| 41 var currentCue = event.target; | |
| 42 assert_equals(currentCue.id, currentCueNumber + ""); | |
| 43 assert_true(video.paused); | |
| 30 | 44 |
| 31 run("video.play()"); | 45 video.play(); |
| 32 testExpected("video.paused", false); | |
| 33 consoleWrite(""); | |
| 34 | 46 |
| 35 waitForEvent('pause', function() { | 47 if (currentCueNumber == 2) |
| 36 waitForEvent('exit', cueExited, false, true, testTrack.track .cues[currentCueNumber]); | 48 t.done(); |
| 37 }); | |
| 38 } | |
| 39 | 49 |
| 40 function cueExited(evt) | 50 currentCueNumber += 2; |
| 41 { | 51 }); |
| 42 currentCue = evt.target; | 52 }); |
| 43 | 53 }); |
| 44 | 54 </script> |
| 45 testExpected("currentCue.id", currentCueNumber); | |
| 46 testExpected("video.paused", true); | |
| 47 | |
| 48 run("video.play()"); | |
| 49 | |
| 50 if (currentCueNumber == 2) | |
| 51 endTest(); | |
| 52 | |
| 53 currentCueNumber += 2; | |
| 54 | |
| 55 consoleWrite(""); | |
| 56 } | |
| 57 | |
| 58 function loaded() | |
| 59 { | |
| 60 trackLoaded = true; | |
| 61 | |
| 62 runTests(); | |
| 63 } | |
| 64 | |
| 65 function bodyLoaded() | |
| 66 { | |
| 67 findMediaElement(); | |
| 68 video.src = findMediaFile("video", "../content/test"); | |
| 69 } | |
| 70 | |
| 71 waitForEventOnce('canplaythrough', function() { | |
| 72 video.currentTime = 4.00; | |
| 73 videoCanPlayThrough = true; | |
| 74 | |
| 75 runTests(); | |
| 76 }); | |
| 77 | |
| 78 </script> | |
| 79 </head> | |
| 80 <body onload="bodyLoaded()"> | |
| 81 <p>Tests that the video is paused after cues that have pause-on-exit fla g are processed</p> | |
| 82 <video controls> | |
| 83 <track id="testTrack" src="captions-webvtt/simple-captions.vtt" onlo ad="loaded()" default> | |
| 84 </video> | |
| 85 </body> | |
| 86 </html> | |
| OLD | NEW |