1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/test/test_bug654550.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=654550 1.8 +--> 1.9 + 1.10 +<head> 1.11 + <title>Test for Bug 654550</title> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 + <script type="text/javascript" src="manifest.js"></script> 1.15 +</head> 1.16 +<body> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=654550">Mozilla Bug 654550</a> 1.18 +<pre id="test"> 1.19 +<script class="testbody" type="text/javascript"> 1.20 + 1.21 + /* Test for Bug 654550 */ 1.22 + 1.23 + // Parallel test must be disabled for media.video_stats.enabled is a global setting 1.24 + // to prevent the setting from changing unexpectedly in the middle of the test. 1.25 + PARALLEL_TESTS = 1; 1.26 + SimpleTest.waitForExplicitFinish(); 1.27 + var manager = new MediaTestManager; 1.28 + 1.29 + function checkStats(v, aShouldBeEnabled) { 1.30 + if (aShouldBeEnabled) { 1.31 + ok(v.mozParsedFrames != 0, 1.32 + "At least one value should be different from 0 if stats are enabled"); 1.33 + } else { 1.34 + ok(!v.mozParsedFrames, 1.35 + "mozParsedFrames should be 0 if stats are disabled"); 1.36 + ok(!v.mozDecodedFrames, 1.37 + "mozDecodedFrames should be 0 if stats are disabled"); 1.38 + ok(!v.mozPresentedFrames, 1.39 + "mozPresentedFrames should be 0 if stats are disabled"); 1.40 + ok(!v.mozPaintedFrames, 1.41 + "mozPaintedFrames should be 0 if stats are disabled"); 1.42 + } 1.43 + 1.44 + } 1.45 + 1.46 + function ontimeupdate_statsEnabled(event) { 1.47 + var v = event.target; 1.48 + v.removeEventListener('timeupdate', ontimeupdate_statsEnabled, false); 1.49 + checkStats(v, true); 1.50 + SpecialPowers.popPrefEnv( 1.51 + function() { 1.52 + v.addEventListener("timeupdate", ontimeupdate_statsDisabled); 1.53 + }); 1.54 + } 1.55 + 1.56 + function ontimeupdate_statsDisabled(event) { 1.57 + var v = event.target; 1.58 + v.removeEventListener('timeupdate', ontimeupdate_statsDisabled, false); 1.59 + checkStats(v, false); 1.60 + removeNodeAndSource(v); 1.61 + manager.finished(v.token); 1.62 + } 1.63 + 1.64 + function startTest(test, token) { 1.65 + var v = document.createElement('video'); 1.66 + v.token = token; 1.67 + v.src = test.name; 1.68 + // playback may reach the end before pref is changed for the duration is short 1.69 + // set 'loop' to true to keep playing so that we won't miss 'timeupdate' events 1.70 + v.loop = true; 1.71 + manager.started(token); 1.72 + SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", true]]}, 1.73 + function() { 1.74 + v.play(); 1.75 + v.addEventListener("timeupdate", ontimeupdate_statsEnabled); 1.76 + }); 1.77 + } 1.78 + 1.79 + SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]}, 1.80 + function() { 1.81 + manager.runTests(gVideoTests, startTest); 1.82 + }); 1.83 + 1.84 +</script> 1.85 +</pre> 1.86 +</body> 1.87 +</html>