content/media/test/test_reset_events_async.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 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=975270
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug </title>
michael@0 9 <script type="application/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="application/javascript" src="manifest.js"></script>
michael@0 12 <script type="application/javascript">
michael@0 13
michael@0 14 /** Test for Bug 975270 **/
michael@0 15 // Test that 'emptied' and 'abort' events are fired asynchronously when re-starting
michael@0 16 // media load.
michael@0 17 SimpleTest.waitForExplicitFinish();
michael@0 18
michael@0 19 var a = document.createElement("audio");
michael@0 20 a._abort = 0;
michael@0 21 a._emptied = 0;
michael@0 22 a.preload = "metadata"; // On B2G we default to preload:none.
michael@0 23
michael@0 24 is(a.networkState, HTMLMediaElement.NETWORK_EMPTY, "Shouldn't be loading");
michael@0 25
michael@0 26 a.addEventListener("abort", function(e) { a._abort++; });
michael@0 27 a.addEventListener("emptied", function(e) { a._emptied++; });
michael@0 28 a.addEventListener("loadedmetadata",
michael@0 29 function(e) {
michael@0 30 is(a._abort, 0, "Should not have received 'abort' before 'loadedmetadata");
michael@0 31 is(a._emptied, 0, "Should not have received 'emptied' before 'loadedmetadata");
michael@0 32
michael@0 33 a.addEventListener("loadstart",
michael@0 34 function(e) {
michael@0 35 is(a._abort, 1, "Should have received 'abort' before 'loadstart");
michael@0 36 is(a._emptied, 1, "Should have received 'emptied' before 'loadstart");
michael@0 37 SimpleTest.finish();
michael@0 38 });
michael@0 39
michael@0 40 a.src = "";
michael@0 41 is(a._abort, 0, "Should not have received 'abort' during setting a.src=''");
michael@0 42 is(a._emptied, 0, "Should not have received 'emptied' during setting a.src=''");
michael@0 43 });
michael@0 44
michael@0 45 a.src = getPlayableAudio(gSmallTests).name;
michael@0 46
michael@0 47 </script>
michael@0 48 </head>
michael@0 49 <body>
michael@0 50 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
michael@0 51 <p id="display"></p>
michael@0 52 <div id="content" style="display: none">
michael@0 53
michael@0 54 </div>
michael@0 55 <pre id="test">
michael@0 56 </pre>
michael@0 57 </body>
michael@0 58 </html>

mercurial