Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test that a MediaStream captured from one element plays back in another</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | <script type="text/javascript" src="manifest.js"></script> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | <pre id="test"> |
michael@0 | 11 | <script class="testbody" type="text/javascript"> |
michael@0 | 12 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 13 | |
michael@0 | 14 | var manager = new MediaTestManager; |
michael@0 | 15 | |
michael@0 | 16 | function checkDrawImage(vout) { |
michael@0 | 17 | var canvas = document.createElement("canvas"); |
michael@0 | 18 | var ctx = canvas.getContext("2d"); |
michael@0 | 19 | ctx.drawImage(vout, 0, 0); |
michael@0 | 20 | var imgData = ctx.getImageData(0, 0, 1, 1); |
michael@0 | 21 | is(imgData.data[3], 255, "Check video frame pixel has been drawn"); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function startTest(test, token) { |
michael@0 | 25 | manager.started(token); |
michael@0 | 26 | |
michael@0 | 27 | var v = document.createElement('video'); |
michael@0 | 28 | var vout = document.createElement('video'); |
michael@0 | 29 | vout.token = token; |
michael@0 | 30 | |
michael@0 | 31 | v.src = test.name; |
michael@0 | 32 | var stream = v.mozCaptureStreamUntilEnded(); |
michael@0 | 33 | is(stream.currentTime, 0, test.name + " stream initial currentTime"); |
michael@0 | 34 | vout.mozSrcObject = stream; |
michael@0 | 35 | is(vout.mozSrcObject, stream, test.name + " set output element .srcObject correctly"); |
michael@0 | 36 | |
michael@0 | 37 | var checkEnded = function(test, vout, stream) { return function() { |
michael@0 | 38 | is(stream.currentTime, vout.currentTime, test.name + " stream final currentTime"); |
michael@0 | 39 | if (test.duration) { |
michael@0 | 40 | ok(Math.abs(vout.currentTime - test.duration) < 0.1, |
michael@0 | 41 | test.name + " current time at end: " + vout.currentTime + " should be: " + test.duration); |
michael@0 | 42 | } |
michael@0 | 43 | is(vout.readyState, vout.HAVE_CURRENT_DATA, test.name + " checking readyState"); |
michael@0 | 44 | ok(vout.ended, test.name + " checking playback has ended"); |
michael@0 | 45 | if (test.type.match(/^video/)) { |
michael@0 | 46 | checkDrawImage(vout); |
michael@0 | 47 | } |
michael@0 | 48 | vout.parentNode.removeChild(vout); |
michael@0 | 49 | manager.finished(vout.token); |
michael@0 | 50 | }}(test, vout, stream); |
michael@0 | 51 | vout.addEventListener("ended", checkEnded, false); |
michael@0 | 52 | |
michael@0 | 53 | document.body.appendChild(vout); |
michael@0 | 54 | v.play(); |
michael@0 | 55 | vout.play(); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | manager.runTests(gSmallTests, startTest); |
michael@0 | 59 | </script> |
michael@0 | 60 | </pre> |
michael@0 | 61 | </body> |
michael@0 | 62 | </html> |