content/media/test/test_autoplay_contentEditable.html

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

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 <head>
michael@0 4 <title>Media test: play() method</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 contenteditable="true">
michael@0 10 <pre id="test">
michael@0 11
michael@0 12 <script>
michael@0 13
michael@0 14 var manager = new MediaTestManager;
michael@0 15
michael@0 16 var tokens = {
michael@0 17 0: ["canplay"],
michael@0 18 "canplay": ["canplay", "canplaythrough"],
michael@0 19 "canplaythrough": ["canplay", "canplaythrough"]
michael@0 20 };
michael@0 21
michael@0 22 function gotPlayEvent(event) {
michael@0 23 var v = event.target;
michael@0 24 ok(tokens[v._state].indexOf(event.type) >= 0,
michael@0 25 "Check expected event got " + event.type + " at " + v._state + " for " + v.src +
michael@0 26 " uneval(event.type)=" + uneval(event.type) + " typeof(event.type)=" + typeof(event.type) +
michael@0 27 " uneval(v._state)=" + uneval(v._state) + " typeof(v._state)=" + typeof(v._state) +
michael@0 28 " tokens["+v._state+"]=" + tokens[v._state] +
michael@0 29 " tokens["+v._state+"].indexOf(event.type)=" + tokens[v._state].indexOf(event.type));
michael@0 30 v._state = event.type;
michael@0 31 }
michael@0 32
michael@0 33 function goToNext(v) {
michael@0 34 v.parentNode.removeChild(v);
michael@0 35 manager.finished(v.token);
michael@0 36 }
michael@0 37
michael@0 38 function initTest(test, token) {
michael@0 39 var v = document.createElement('video');
michael@0 40 v.preload = "metadata";
michael@0 41 v.token = token;
michael@0 42 manager.started(token);
michael@0 43 v._state = 0;
michael@0 44
michael@0 45 ["play", "canplay", "playing", "canplaythrough", "ended"].forEach(function (e) {
michael@0 46 v.addEventListener(e, gotPlayEvent, false);
michael@0 47 });
michael@0 48
michael@0 49 setTimeout(function() goToNext(v), 500);
michael@0 50
michael@0 51 v.src = test.name;
michael@0 52 v.autoplay = true;
michael@0 53 document.body.appendChild(v); // Causes load.
michael@0 54 }
michael@0 55
michael@0 56 manager.runTests(gSmallTests, initTest);
michael@0 57
michael@0 58 </script>
michael@0 59 </pre>
michael@0 60 </body>
michael@0 61 </html>

mercurial