content/media/test/test_play_events.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial