Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | function test_seek2(v, seekTime, is, ok, finish) { |
michael@0 | 2 | |
michael@0 | 3 | // Test seeking works if current time is set before video is |
michael@0 | 4 | // playing. |
michael@0 | 5 | var startPassed = false; |
michael@0 | 6 | var endPassed = false; |
michael@0 | 7 | var completed = false; |
michael@0 | 8 | |
michael@0 | 9 | function startTest() { |
michael@0 | 10 | if (completed) |
michael@0 | 11 | return; |
michael@0 | 12 | |
michael@0 | 13 | v.currentTime=seekTime; |
michael@0 | 14 | v.play(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | function seekStarted() { |
michael@0 | 18 | if (completed) |
michael@0 | 19 | return; |
michael@0 | 20 | |
michael@0 | 21 | ok(v.currentTime >= seekTime - 0.1, "Video currentTime should be around " + seekTime + ": " + v.currentTime); |
michael@0 | 22 | startPassed = true; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function seekEnded() { |
michael@0 | 26 | if (completed) |
michael@0 | 27 | return; |
michael@0 | 28 | |
michael@0 | 29 | endPassed = true; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function playbackEnded() { |
michael@0 | 33 | if (completed) |
michael@0 | 34 | return; |
michael@0 | 35 | |
michael@0 | 36 | completed = true; |
michael@0 | 37 | ok(startPassed, "send seeking event"); |
michael@0 | 38 | ok(endPassed, "send seeked event"); |
michael@0 | 39 | ok(v.ended, "Checking playback has ended"); |
michael@0 | 40 | ok(Math.abs(v.currentTime - v.duration) <= 0.1, "Checking currentTime at end: " + v.currentTime); |
michael@0 | 41 | finish(); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | v.addEventListener("ended", playbackEnded, false); |
michael@0 | 45 | v.addEventListener("loadedmetadata", startTest, false); |
michael@0 | 46 | v.addEventListener("seeking", seekStarted, false); |
michael@0 | 47 | v.addEventListener("seeked", seekEnded, false); |
michael@0 | 48 | |
michael@0 | 49 | } |