content/media/test/test_invalid_reject.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 <meta charset="UTF-8" />
michael@0 5 <title>Test rejection of invalid files</title>
michael@0 6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 8 <script type="text/javascript" src="manifest.js"></script>
michael@0 9 </head>
michael@0 10 <body>
michael@0 11 <pre id="test">
michael@0 12 <script class="testbody" type="text/javascript">
michael@0 13
michael@0 14 var manager = new MediaTestManager;
michael@0 15
michael@0 16 function startTest(test, token) {
michael@0 17 var v = document.createElement('video');
michael@0 18 manager.started(token);
michael@0 19
michael@0 20 // Set up event handlers. Seeing any of these is a failure.
michael@0 21 function badEvent(type) { return function(e) {
michael@0 22 ok(false, test.name + " should not fire '" + type + "' event");
michael@0 23 }};
michael@0 24 var events = [
michael@0 25 'loadedmetadata', 'load',
michael@0 26 'canplay', 'canplaythrough',
michael@0 27 'playing'
michael@0 28 ];
michael@0 29 events.forEach( function(e) {
michael@0 30 v.addEventListener(e, badEvent(e));
michael@0 31 });
michael@0 32
michael@0 33 // Seeing a decoder error is a success.
michael@0 34 v.addEventListener("error", function(e) {
michael@0 35 is(v.error.code, v.error.MEDIA_ERR_DECODE,
michael@0 36 "decoder should reject " + test.name);
michael@0 37 v.removeEventListener('error', arguments.callee, false);
michael@0 38 manager.finished(token);
michael@0 39 });
michael@0 40
michael@0 41 // Now try to load and play the file, which should result in the
michael@0 42 // error event handler above being called, terminating the test.
michael@0 43 document.body.appendChild(v);
michael@0 44 v.src = test.name;
michael@0 45 v.play();
michael@0 46 }
michael@0 47
michael@0 48 manager.runTests(gInvalidTests, startTest);
michael@0 49
michael@0 50 </script>
michael@0 51 </pre>
michael@0 52 </body>
michael@0 53 </html>

mercurial