1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/test/test_reset_events_async.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=975270 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug </title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 + <script type="application/javascript" src="manifest.js"></script> 1.15 + <script type="application/javascript"> 1.16 + 1.17 + /** Test for Bug 975270 **/ 1.18 + // Test that 'emptied' and 'abort' events are fired asynchronously when re-starting 1.19 + // media load. 1.20 + SimpleTest.waitForExplicitFinish(); 1.21 + 1.22 + var a = document.createElement("audio"); 1.23 + a._abort = 0; 1.24 + a._emptied = 0; 1.25 + a.preload = "metadata"; // On B2G we default to preload:none. 1.26 + 1.27 + is(a.networkState, HTMLMediaElement.NETWORK_EMPTY, "Shouldn't be loading"); 1.28 + 1.29 + a.addEventListener("abort", function(e) { a._abort++; }); 1.30 + a.addEventListener("emptied", function(e) { a._emptied++; }); 1.31 + a.addEventListener("loadedmetadata", 1.32 + function(e) { 1.33 + is(a._abort, 0, "Should not have received 'abort' before 'loadedmetadata"); 1.34 + is(a._emptied, 0, "Should not have received 'emptied' before 'loadedmetadata"); 1.35 + 1.36 + a.addEventListener("loadstart", 1.37 + function(e) { 1.38 + is(a._abort, 1, "Should have received 'abort' before 'loadstart"); 1.39 + is(a._emptied, 1, "Should have received 'emptied' before 'loadstart"); 1.40 + SimpleTest.finish(); 1.41 + }); 1.42 + 1.43 + a.src = ""; 1.44 + is(a._abort, 0, "Should not have received 'abort' during setting a.src=''"); 1.45 + is(a._emptied, 0, "Should not have received 'emptied' during setting a.src=''"); 1.46 + }); 1.47 + 1.48 + a.src = getPlayableAudio(gSmallTests).name; 1.49 + 1.50 + </script> 1.51 +</head> 1.52 +<body> 1.53 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> 1.54 +<p id="display"></p> 1.55 +<div id="content" style="display: none"> 1.56 + 1.57 +</div> 1.58 +<pre id="test"> 1.59 +</pre> 1.60 +</body> 1.61 +</html>