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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=495145 |
michael@0 | 5 | --> |
michael@0 | 6 | |
michael@0 | 7 | <head> |
michael@0 | 8 | <title>Bug 495145 - pausing while ended shouldn't cause problems</title> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | <script type="text/javascript" src="manifest.js"></script> |
michael@0 | 12 | |
michael@0 | 13 | </head> |
michael@0 | 14 | <body> |
michael@0 | 15 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495145">Mozilla Bug 495145</a> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | <script class="testbody" type="text/javascript"> |
michael@0 | 18 | |
michael@0 | 19 | var manager = new MediaTestManager; |
michael@0 | 20 | |
michael@0 | 21 | function start(e) { |
michael@0 | 22 | e.target.play(); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function ended1(e) { |
michael@0 | 26 | var v = e.target; |
michael@0 | 27 | if (v._finished) |
michael@0 | 28 | return; |
michael@0 | 29 | |
michael@0 | 30 | ++v._endCount; |
michael@0 | 31 | if (v._endCount == 2) { |
michael@0 | 32 | ok(true, "Playing after pause while ended works for " + v._name); |
michael@0 | 33 | v._finished = true; |
michael@0 | 34 | v.removeEventListener("loadedmetadata", start, false); |
michael@0 | 35 | v.removeEventListener("ended", ended1, false); |
michael@0 | 36 | removeNodeAndSource(v); |
michael@0 | 37 | manager.finished(v.token); |
michael@0 | 38 | return; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | v.pause(); |
michael@0 | 42 | v.play(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function ended2(e) { |
michael@0 | 46 | var v = e.target; |
michael@0 | 47 | if (v._finished) |
michael@0 | 48 | return; |
michael@0 | 49 | |
michael@0 | 50 | v.pause(); |
michael@0 | 51 | v.currentTime = 0; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function seeked2(e) { |
michael@0 | 55 | var v = e.target; |
michael@0 | 56 | if (v._finished) |
michael@0 | 57 | return; |
michael@0 | 58 | |
michael@0 | 59 | ok(v.paused, "Paused after seek after pause while ended for " + v._name); |
michael@0 | 60 | v._finished = true; |
michael@0 | 61 | v.removeEventListener("loadedmetadata", start, false); |
michael@0 | 62 | v.removeEventListener("ended", ended2, false); |
michael@0 | 63 | v.removeEventListener("seeked", seeked2, false); |
michael@0 | 64 | removeNodeAndSource(v); |
michael@0 | 65 | manager.finished(v.token); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function createVideo(test, x, token) { |
michael@0 | 69 | var v = document.createElement('video'); |
michael@0 | 70 | v.preload = "auto"; |
michael@0 | 71 | v.token = token; |
michael@0 | 72 | manager.started(token); |
michael@0 | 73 | v.src = test.name; |
michael@0 | 74 | v._name = test.name + "#" + x; |
michael@0 | 75 | v._endCount = 0; |
michael@0 | 76 | v._finished = false; |
michael@0 | 77 | v.addEventListener("loadedmetadata", start, false); |
michael@0 | 78 | v.addEventListener("ended", x == 1 ? ended1 : ended2, false); |
michael@0 | 79 | if (x == 2) |
michael@0 | 80 | v.addEventListener("seeked", seeked2, false); |
michael@0 | 81 | document.body.appendChild(v); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function startTest(test, token) { |
michael@0 | 85 | createVideo(test, 1, token + "a"); |
michael@0 | 86 | createVideo(test, 2, token + "b"); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | manager.runTests(gSmallTests, startTest); |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | </script> |
michael@0 | 93 | </pre> |
michael@0 | 94 | </body> |
michael@0 | 95 | </html> |