Backed out changeset 4cb1973f06b9 (bug 868439) for Android M2 failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 21 May 2013 10:48:09 -0400
changeset 144876 0a830609f6197d2b786a97bbd99bd0412ff5c052
parent 144875 0e3678635f5b528218729e1e0059bf12736e5106
child 144877 97f49d0b228c2b8e5a770fdc1ff0b17c9b3a6e2a
child 144903 474b681d38bef1504e34cb4419d458a4a0d5eef1
push id368
push userbbajaj@mozilla.com
push dateMon, 09 Sep 2013 22:57:58 +0000
treeherdermozilla-release@5a4f47ae1217 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs868439
milestone24.0a1
backs out4cb1973f06b9abf494c1e2cb77f943a21ad2adce
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 4cb1973f06b9 (bug 868439) for Android M2 failures. CLOSED TREE
content/media/test/Makefile.in
content/media/test/manifest.js
content/media/test/test_buffered.html
content/media/test/test_bug493187.html
content/media/test/test_can_play_type_mpeg.html
content/media/test/test_closing_connections.html
content/media/test/test_decode_error.html
content/media/test/test_preload_actions.html
content/media/test/test_preload_suspend.html
content/media/test/test_progress.html
content/media/test/test_video_to_canvas.html
content/media/test/use_large_cache.js
layout/forms/test/test_bug411236.html
toolkit/content/tests/widgets/Makefile.in
toolkit/content/tests/widgets/test_audiocontrols_dimensions.html
toolkit/content/tests/widgets/test_videocontrols.html
toolkit/content/tests/widgets/test_videocontrols_audio_direction.html
toolkit/content/tests/widgets/test_videocontrols_video_direction.html
toolkit/content/tests/widgets/use_large_cache.js
toolkit/content/tests/widgets/videocontrols_direction_test.js
--- a/content/media/test/Makefile.in
+++ b/content/media/test/Makefile.in
@@ -113,16 +113,17 @@ MOCHITEST_FILES = \
 		test_seek_out_of_range.html \
 		test_source.html \
 		test_source_write.html \
 		test_source_null.html \
 		test_standalone.html \
 		test_too_many_elements.html \
 		test_volume.html \
 		test_video_to_canvas.html \
+		use_large_cache.js \
 		test_audiowrite.html \
 		test_mozHasAudio.html \
 		test_source_media.html \
 		test_autoplay_contentEditable.html \
 		test_buffered.html \
 		test_bug448534.html \
 		test_bug463162.xhtml \
 		test_decoder_disable.html \
--- a/content/media/test/manifest.js
+++ b/content/media/test/manifest.js
@@ -553,18 +553,17 @@ function MediaTestManager() {
     this.testNum = 0;
     this.tests = tests;
     this.startTest = startTest;
     this.tokens = [];
     this.isShutdown = false;
     this.numTestsRunning = 0;
     // Always wait for explicit finish.
     SimpleTest.waitForExplicitFinish();
-
-    SpecialPowers.pushPrefEnv({"set": [["media.preload.default", 2], ["media.preload.auto", 3], ["media.opus.enabled", true]]}, function(aThis) {aThis.nextTest();}(this));
+    this.nextTest();
   }
   
   // Registers that the test corresponding to 'token' has been started.
   // Don't call more than once per token.
   this.started = function(token) {
     this.tokens.push(token);
     this.numTestsRunning++;
     is(this.numTestsRunning, this.tokens.length, "[started " + token + "] Length of array should match number of running tests");
@@ -642,8 +641,36 @@ function mediaTestCleanup() {
     }
     var A = document.getElementsByTagName("audio");
     for (i=0; i<A.length; i++) {
       A[i].parentNode.removeChild(A[i]);
       A[i] = null;
     }
     SpecialPowers.forceGC();
 }
+
+(function() {
+  // Ensure that preload preferences are comsistent
+  var prefService = SpecialPowers.wrap(SpecialPowers.Components)
+                                 .classes["@mozilla.org/preferences-service;1"]
+                                 .getService(SpecialPowers.Ci.nsIPrefService);
+  var branch = prefService.getBranch("media.");
+  var oldDefault = 2;
+  var oldAuto = 3;
+  var oldOpus = undefined;
+  try {
+    oldDefault = branch.getIntPref("preload.default");
+    oldAuto    = branch.getIntPref("preload.auto");
+    oldOpus    = branch.getBoolPref("opus.enabled");
+  } catch(ex) { }
+  branch.setIntPref("preload.default", 2); // preload_metadata
+  branch.setIntPref("preload.auto", 3); // preload_enough
+  // test opus playback iff the pref exists
+  if (oldOpus !== undefined)
+    branch.setBoolPref("opus.enabled", true);
+
+  window.addEventListener("unload", function() {
+    branch.setIntPref("preload.default", oldDefault);
+    branch.setIntPref("preload.auto", oldAuto);
+    if (oldOpus !== undefined)
+      branch.setBoolPref("opus.enabled", oldOpus);
+  }, false);
+ })();
--- a/content/media/test/test_buffered.html
+++ b/content/media/test/test_buffered.html
@@ -3,16 +3,17 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=462957
 -->
 <head>
   <title>Test for Bug 462957</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="text/javascript" src="manifest.js"></script>
+  <script type="application/javascript" src="use_large_cache.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462957">Mozilla Bug 462957</a>
 
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
@@ -79,17 +80,14 @@ function startTest(test, token) {
   v._name = test.name;
   v._test = test;
   v._finished = false;
   v.autoplay = true;
   v.addEventListener("ended", ended, false);
   document.body.appendChild(v);
 }
 
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  manager.runTests(gSeekTests, startTest);
-}
+manager.runTests(gSeekTests, startTest);
+
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_bug493187.html
+++ b/content/media/test/test_bug493187.html
@@ -3,16 +3,17 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=493187
 -->
 
 <head>
   <title>Bug 493187 - enter HAVE_FUTURE_DATA when seeking within buffered data even if new data isn't arriving</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="use_large_cache.js"></script>
   <script type="text/javascript" src="manifest.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=493187">Mozilla Bug 493187</a>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.expectAssertions(0, 2);
@@ -56,17 +57,14 @@ function startTest(test, token) {
   v._finished = false;
   v.preload = "auto";
   v.addEventListener("loadedmetadata", start, false);
   v.addEventListener("canplaythrough", canPlayThrough, false);
   v.addEventListener("seeking", startSeeking, false);
   document.body.appendChild(v);
 }
 
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  manager.runTests(gSeekTests, startTest);
-}
+manager.runTests(gSeekTests, startTest);
+
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_can_play_type_mpeg.html
+++ b/content/media/test/test_can_play_type_mpeg.html
@@ -28,27 +28,34 @@ function IsWindowsVistaOrLater() {
 
 function IsWindows7() {
   var re = /Windows NT (\d.\d)/;
   var winver = navigator.userAgent.match(re);
   return winver && winver.length == 2 && parseFloat(winver[1]) == 6.1;
 }
 
 function getMediaPref(name) {
+  // Can't use SpecialPowers.getBoolPref because it throws when pref isn't
+  // present, and for example on non-Windows systems the WMF prefs won't be
+  // present.
   var pref = false;
+  var prefService = SpecialPowers.wrap(SpecialPowers.Components)
+                                 .classes["@mozilla.org/preferences-service;1"]
+                                 .getService(SpecialPowers.Ci.nsIPrefService);
+  var branch = prefService.getBranch("media.");
   try {
-    pref = SpecialPowers.getBoolPref(name);
+    pref = branch.getBoolPref(name);
   } catch(ex) { }
   return pref;
 }
 
-var haveMp4 = (getMediaPref("media.windows-media-foundation.enabled") && IsWindowsVistaOrLater()) ||
-               getMediaPref("media.omx.enabled") ||
-               getMediaPref("media.gstreamer.enabled");
-// TODO:  Add "getMediaPref("media.plugins.enabled")" once MP4 works on Gingerbread.
+var haveMp4 = (getMediaPref("windows-media-foundation.enabled") && IsWindowsVistaOrLater()) ||
+               getMediaPref("omx.enabled") ||
+               getMediaPref("gstreamer.enabled");
+// TODO:  Add "getMediaPref("plugins.enabled")" once MP4 works on Gingerbread.
              
 check_mp4(document.getElementById('v'), haveMp4);
 
 if (!IsWindows7()) {
   // Don't check MP3 support on Windows 7. MP3 is disabled on Win7SP0 (bug 852915),
   // and there's no easy way from JS to distinguish which service pack is installed
   // on a users system, so we just won't test it. We'll get MP3 support on Win7SP0
   // via DirectShow once bug 861693 lands.
--- a/content/media/test/test_closing_connections.html
+++ b/content/media/test/test_closing_connections.html
@@ -27,30 +27,27 @@ window.onload = function() {
 /*   With normal per-domain connection limits and a naive implementation, we
      won't ever be able to load all these videos because the first 15 (or whatever)
      will each take up one HTTP connection (which will be suspended) and then
      the others will be blocked by the per-domain HTTP connection limit. We
      pass this test by closing the connection for non-buffered videos after
      we've got the first frame.
 */
 
+
 var resource = getPlayableVideo(gSeekTests);
-
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  if (resource != null) {
-    for (var i=0; i<20; ++i) {
-      var v = document.createElement("video");
-      v.src = resource.name;
-      document.body.appendChild(v);
-    }
-  } else {
-    todo(false, "No types supported");
+if (resource != null) {
+  for (var i=0; i<20; ++i) {
+    var v = document.createElement("video");
+    v.src = resource.name;
+    document.body.appendChild(v);
   }
+  SimpleTest.waitForExplicitFinish();
+} else {
+  todo(false, "No types supported");
 }
 </script>
 
 <pre id="test">
 <script type="application/javascript">
 </script>
 </pre>
 </body>
--- a/content/media/test/test_decode_error.html
+++ b/content/media/test/test_decode_error.html
@@ -1,14 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Media test: unknown/invalid formats raise decode error</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="use_large_cache.js"></script>
   <script type="text/javascript" src="manifest.js"></script>
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 var manager = new MediaTestManager;
 
 function startTest(test, token) {
@@ -38,17 +39,14 @@ function startTest(test, token) {
   v.autoplay = true;
   v.addEventListener("ended", function () {
     ok(false, "Unexpected ended event");
   }, false);
 
   v.src = test.name; // implicitly starts a load.
 }
 
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  manager.runTests(gDecodeErrorTests, startTest);
-}
+manager.runTests(gDecodeErrorTests, startTest);
+
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_preload_actions.html
+++ b/content/media/test/test_preload_actions.html
@@ -3,16 +3,17 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=548523
 -->
 <head>
   <title>Test for Bug 548523</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="text/javascript" src="manifest.js"></script>
+  <script type="text/javascript" src="use_large_cache.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548523">Mozilla Bug 548523</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <!-- <button onClick="SimpleTest.finish();">Finish</button> -->
@@ -562,17 +563,14 @@ function startTest(test, token) {
   }
   var v = document.createElement("video");
   v.token = token;
   test.setup(v);
   manager.started(token);
 }
 
 var twiceTests = tests.concat(tests);
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  manager.runTests(twiceTests, startTest);
-}
+manager.runTests(twiceTests, startTest);
+
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_preload_suspend.html
+++ b/content/media/test/test_preload_suspend.html
@@ -2,16 +2,17 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=479863
 -->
 <head>
   <title>Test for Bug 479863</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="use_large_cache.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479863">Mozilla Bug 479863</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 
@@ -64,27 +65,23 @@ function suspended(event) {
   } else if (event.target.id == "v5") {
     event.target.currentTime = 0.1;
   } else if (event.target.id == "v6") {
     event.target.autoplay = true;
   }
 }
 
 var key = Math.random();
-
+for (var i = 1; i <= 6; ++i) {
+  var id = "v" + i;
+  var v = document.getElementById(id);
+  suspendCount[id] = 0;
+  v.addEventListener("suspend", suspended, false);
+  // Treat "load" as "suspend" for now, it means the same thing: we
+  // stopped the download.
+  v.addEventListener("load", suspended, false);
+  v.src = "seek.ogv?key=" + key + "&id=" + id;
+}
 SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  for (var i = 1; i <= 6; ++i) {
-    var id = "v" + i;
-    var v = document.getElementById(id);
-    suspendCount[id] = 0;
-    v.addEventListener("suspend", suspended, false);
-    // Treat "load" as "suspend" for now, it means the same thing: we
-    // stopped the download.
-    v.addEventListener("load", suspended, false);
-    v.src = "seek.ogv?key=" + key + "&id=" + id;
-  }
-}
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_progress.html
+++ b/content/media/test/test_progress.html
@@ -3,16 +3,17 @@
 <head>
   <title>Media test: progress events</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
   <script type="text/javascript" src="manifest.js"></script>
 </head>
 <body>
 <pre id="test">
+<script src="use_large_cache.js"></script>
 <script class="testbody" type="text/javascript">
 
 var manager = new MediaTestManager;
 
 function do_progress(e) {
   var v = e.target;
   ok(!v._finished, "Check no progress events after completed for " + v._name);
 }
@@ -34,17 +35,14 @@ function startTest(test, token) {
   v.autoplay = true;
   v._name = test.name;
   v._finished = false;
   v.addEventListener("ended", do_ended, false);
   v.addEventListener("progress", do_progress, false);
   document.body.appendChild(v);
 }
 
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  manager.runTests(gProgressTests, startTest);
-}
+manager.runTests(gProgressTests, startTest);
+
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_video_to_canvas.html
+++ b/content/media/test/test_video_to_canvas.html
@@ -4,16 +4,17 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=486646
 -->
 
 <head>
   <title>Test for Bug 486646</title>
   <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="use_large_cache.js"></script>
   <script type="text/javascript" src="manifest.js"></script>
 </head>
 <body>
 <script class="testbody" type="text/javascript">
 
 var manager = new MediaTestManager;
 
 function loaded(e) {
@@ -50,19 +51,16 @@ function startTest(test, token) {
   v._name = test.name;
   v._finished = false;
   v.autoplay = true;
   v.style.display = "none";
   v.addEventListener("ended", loaded, false);
   document.body.appendChild(v);
 }
 
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
-function beginTest() {
-  manager.runTests(gSmallTests, startTest);
-}
+manager.runTests(gSmallTests, startTest);
+
 
 </script>
 </pre>
 
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/content/media/test/use_large_cache.js
@@ -0,0 +1,14 @@
+(function() {
+  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+  // Set cache size to something large
+  var prefService = Components.classes["@mozilla.org/preferences-service;1"]
+                               .getService(Components.interfaces.nsIPrefService);
+  var branch = prefService.getBranch("media.");
+  var oldSize = branch.getIntPref("cache_size");
+  branch.setIntPref("cache_size", 40000);
+
+  window.addEventListener("unload", function() {
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+    branch.setIntPref("cache_size", oldSize);
+  }, false);
+ })();
--- a/layout/forms/test/test_bug411236.html
+++ b/layout/forms/test/test_bug411236.html
@@ -19,16 +19,30 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 411236 **/
 
 window.oTarget = null;
 window.fileInputGotClick = false;
 
+// accessibility.tabfocus must be set to value 7 before running test also
+// on a mac.
+function setOrRestoreTabFocus(newValue) {
+  const prefSvcContractID = "@mozilla.org/preferences-service;1";
+  const prefSvcIID = SpecialPowers.Ci.nsIPrefService;
+  var prefs = SpecialPowers.Cc[prefSvcContractID].getService(prefSvcIID)
+                                                   .getBranch("accessibility.");
+  if (!newValue) {
+    prefs.clearUserPref("tabfocus");
+  } else {
+    prefs.setIntPref("tabfocus", newValue);
+  }
+}
+
 function tab() {
   var utils = SpecialPowers.DOMWindowUtils;
   // Send tab key events.
   var key = SpecialPowers.Ci.nsIDOMKeyEvent.DOM_VK_TAB;
   utils.sendKeyEvent("keydown", key, 0, 0);
   utils.sendKeyEvent("keypress", key, 0, 0);
   utils.sendKeyEvent("keyup", key, 0, 0);
 }
@@ -38,42 +52,40 @@ function test() {
   var i = 0;
   while (!window.oTarget && i < 100) {
     ++i;
     tab();
   }
 
   if (i >= 100) {
     ok(false, "Couldn't find an input element!");
+    setOrRestoreTabFocus(0);
     SimpleTest.finish();
     return;
   }
 
   ok(window.oTarget instanceof HTMLButtonElement, "Should have focused an input element!")
   ok(SpecialPowers.wrap(window.oTarget).type == "button", "Should have focused 'Browse...' button!");
   var e = document.createEvent("mouseevents");
   e.initMouseEvent("click", true, true, window, 0, 1, 1, 1, 1,
                     false, false, false, false, 0, null);
   SpecialPowers.wrap(window.oTarget).dispatchEvent(e);
   ok(window.fileInputGotClick,
      "File input should have got a click event, but not open the file dialog.");
+  setOrRestoreTabFocus(0);
   SimpleTest.finish();
 }
 
-function beginTest() {
-  // accessibility.tabfocus must be set to value 7 before running test also
-  // on a mac.
-  SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]}, do_test);
-}
-
 function do_test() {
+  setOrRestoreTabFocus(7);
   window.focus();
   document.getElementById('fileinput').focus();
   setTimeout(test, 100);
 }
 
 SimpleTest.waitForExplicitFinish();
-addLoadEvent(beginTest);
+addLoadEvent(do_test);
 
 </script>
 </pre>
 </body>
 </html>
+
--- a/toolkit/content/tests/widgets/Makefile.in
+++ b/toolkit/content/tests/widgets/Makefile.in
@@ -33,16 +33,17 @@ MOCHITEST_FILES =	\
 		videocontrols_direction-1e.html \
 		videocontrols_direction-2-ref.html \
 		videocontrols_direction-2a.html \
 		videocontrols_direction-2b.html \
 		videocontrols_direction-2c.html \
 		videocontrols_direction-2d.html \
 		videocontrols_direction-2e.html \
 		videocontrols_direction_test.js \
+		use_large_cache.js \
 		$(topsrcdir)/content/media/test/audio.wav \
 		$(topsrcdir)/content/media/test/seek_with_sound.ogg \
 		videomask.css \
 		$(NULL)
 
 MOCHITEST_CHROME_FILES = \
 		tree_shared.js \
 		test_tree_column_reorder.xul \
--- a/toolkit/content/tests/widgets/test_audiocontrols_dimensions.html
+++ b/toolkit/content/tests/widgets/test_audiocontrols_dimensions.html
@@ -9,30 +9,29 @@
 <body>
 <p id="display"></p>
 
 <div id="content">
   <audio id="audio" controls preload="auto"></audio>
 </div>
 
 <pre id="test">
+<script type="text/javascript" src="use_large_cache.js"></script>
 <script class="testbody" type="text/javascript">
   function loadedmetadata(event) {
     is(event.type, "loadedmetadata", "checking event type");
     is(audio.clientHeight, "28", "checking height of audio element");
 
     SimpleTest.finish();
   }
 
   var audio = document.getElementById("audio");
 
-  SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, startTest);
-  function startTest() {
-    // Kick off test once audio has loaded.
-    audio.addEventListener("loadedmetadata", loadedmetadata, false);
-    audio.src = "audio.wav";
-  }
+  // Kick off test once audio has loaded.
+  audio.addEventListener("loadedmetadata", loadedmetadata, false);
+  audio.src = "audio.wav";
 
   SimpleTest.waitForExplicitFinish();
+
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -9,16 +9,17 @@
 <body>
 <p id="display"></p>
 
 <div id="content">
   <video width="320" height="240" id="video" src="seek_with_sound.ogg" controls mozNoDynamicControls preload="auto"></video>
 </div>
 
 <pre id="test">
+<script type="text/javascript" src="use_large_cache.js"></script>
 <script class="testbody" type="text/javascript">
 
 /*
  * Positions of the  UI elements, relative to the upper-left corner of the
  * <video> box.
  */
 const videoWidth = 320;
 const videoHeight = 240;
@@ -232,28 +233,25 @@ function maybeStartTest() {
     return;
 
   setTimeout("runTest(canplaythroughsavedevent);", 0);
 }
 
 var testnum = 1;
 var video = document.getElementById("video");
 
-SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, startTest);
-function startTest() {
-  // Kick off test once video has loaded.
-  video.addEventListener("canplaythrough",  canplaythroughevent, false);
-  window.addEventListener("load",  loadevent, false);
+// Kick off test once video has loaded.
+video.addEventListener("canplaythrough",  canplaythroughevent, false);
+window.addEventListener("load",  loadevent, false);
 
-  // Other events expected by the test.
-  video.addEventListener("play",  runTest, false);
-  video.addEventListener("pause", runTest, false);
-  video.addEventListener("volumechange", runTest, false);
-  video.addEventListener("seeking", runTest, false);
-  video.addEventListener("seeked", runTest, false);
-}
+// Other events expected by the test.
+video.addEventListener("play",  runTest, false);
+video.addEventListener("pause", runTest, false);
+video.addEventListener("volumechange", runTest, false);
+video.addEventListener("seeking", runTest, false);
+video.addEventListener("seeked", runTest, false);
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/content/tests/widgets/test_videocontrols_audio_direction.html
+++ b/toolkit/content/tests/widgets/test_videocontrols_audio_direction.html
@@ -20,12 +20,13 @@ var tests = [
   {op: "==", test: "videocontrols_direction-2a.html", ref: "videocontrols_direction-2-ref.html"},
   {op: "==", test: "videocontrols_direction-2b.html", ref: "videocontrols_direction-2-ref.html"},
   {op: "==", test: "videocontrols_direction-2c.html", ref: "videocontrols_direction-2-ref.html"},
   {op: "==", test: "videocontrols_direction-2d.html", ref: "videocontrols_direction-2-ref.html"},
   {op: "==", test: "videocontrols_direction-2e.html", ref: "videocontrols_direction-2-ref.html"}
 ];
 
 </script>
+<script type="text/javascript" src="use_large_cache.js"></script>
 <script type="text/javascript" src="videocontrols_direction_test.js"></script>
 </pre>
 </body>
 </html>
--- a/toolkit/content/tests/widgets/test_videocontrols_video_direction.html
+++ b/toolkit/content/tests/widgets/test_videocontrols_video_direction.html
@@ -20,12 +20,13 @@ var tests = [
   {op: "==", test: "videocontrols_direction-1a.html", ref: "videocontrols_direction-1-ref.html"},
   {op: "==", test: "videocontrols_direction-1b.html", ref: "videocontrols_direction-1-ref.html"},
   {op: "==", test: "videocontrols_direction-1c.html", ref: "videocontrols_direction-1-ref.html"},
   {op: "==", test: "videocontrols_direction-1d.html", ref: "videocontrols_direction-1-ref.html"},
   {op: "==", test: "videocontrols_direction-1e.html", ref: "videocontrols_direction-1-ref.html"},
 ];
 
 </script>
+<script type="text/javascript" src="use_large_cache.js"></script>
 <script type="text/javascript" src="videocontrols_direction_test.js"></script>
 </pre>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/widgets/use_large_cache.js
@@ -0,0 +1,12 @@
+(function() {
+  // Set cache size to something large
+  var prefService = SpecialPowers.Cc["@mozilla.org/preferences-service;1"]
+                               .getService(SpecialPowers.Ci.nsIPrefService);
+  var branch = prefService.getBranch("media.");
+  var oldSize = branch.getIntPref("cache_size");
+  branch.setIntPref("cache_size", 40000);
+
+  window.addEventListener("unload", function() {
+    branch.setIntPref("cache_size", oldSize);
+  }, false);
+ })();
--- a/toolkit/content/tests/widgets/videocontrols_direction_test.js
+++ b/toolkit/content/tests/widgets/videocontrols_direction_test.js
@@ -82,11 +82,9 @@ function runTest(index) {
   testCanvas.load(testCallback);
 
   var refCanvas = new RemoteCanvas(currentTest.ref, "ref-" + index);
   refCanvas.load(testCallback);
 }
 
 SimpleTest.waitForExplicitFinish();
 
-window.addEventListener("load", function() {
-  SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, function(){ runTest(0); });
-}, true);
+window.addEventListener("load", function() { runTest(0); }, true);