Bug 868439 - Convert some uses of nsIPrefBranch to SpecialPowers. r=jmaher
authorMartijn Wargers <mwargers@mozilla.com>
Sat, 15 Jun 2013 00:13:44 +0200
changeset 135181 09fcb384c6a0f61db6fc6484bad1806832676edd
parent 135180 6503457c2561b84d5939ebdf81b574836f603a05
child 135182 02c15958f05c4ece823a7cfc944c207aa44fbeff
push id24830
push userryanvm@gmail.com
push dateSun, 16 Jun 2013 01:34:51 +0000
treeherdermozilla-central@36da3cb92193 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs868439
milestone24.0a1
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
Bug 868439 - Convert some uses of nsIPrefBranch to SpecialPowers. r=jmaher
content/media/test/Makefile.in
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
@@ -112,17 +112,16 @@ 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/test_buffered.html
+++ b/content/media/test/test_buffered.html
@@ -3,17 +3,16 @@
 <!--
 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>
@@ -80,14 +79,17 @@ 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);
 }
 
-manager.runTests(gSeekTests, startTest);
-
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
+function beginTest() {
+  manager.runTests(gSeekTests, startTest);
+}
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_bug493187.html
+++ b/content/media/test/test_bug493187.html
@@ -3,17 +3,16 @@
 <!--
 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);
@@ -57,14 +56,17 @@ 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);
 }
 
-manager.runTests(gSeekTests, startTest);
-
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
+function beginTest() {
+  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,34 +28,27 @@ 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 = branch.getBoolPref(name);
+    pref = SpecialPowers.getBoolPref(name);
   } catch(ex) { }
   return pref;
 }
 
-var haveMp4 = (getMediaPref("windows-media-foundation.enabled") && IsWindowsVistaOrLater()) ||
-               getMediaPref("omx.enabled") ||
-               getMediaPref("gstreamer.enabled");
-// TODO:  Add "getMediaPref("plugins.enabled")" once MP4 works on Gingerbread.
+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.
              
 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
@@ -1,9 +1,9 @@
-<!DOCTYPE HTML>
+hg diff<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=479863
 -->
 <head>
   <title>Test for Bug 479863 --- loading many connections</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
@@ -27,27 +27,30 @@ 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);
 
-var resource = getPlayableVideo(gSeekTests);
-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();
+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");
   }
-  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,15 +1,14 @@
 <!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) {
@@ -39,14 +38,17 @@ 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.
 }
 
-manager.runTests(gDecodeErrorTests, startTest);
-
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
+function beginTest() {
+  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,17 +3,16 @@
 <!--
 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> -->
@@ -563,14 +562,17 @@ function startTest(test, token) {
   }
   var v = document.createElement("video");
   v.token = token;
   test.setup(v);
   manager.started(token);
 }
 
 var twiceTests = tests.concat(tests);
-manager.runTests(twiceTests, startTest);
-
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
+function beginTest() {
+  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,17 +2,16 @@
 <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>
 
@@ -65,23 +64,27 @@ 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;
+  }
 }
-SimpleTest.waitForExplicitFinish();
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_progress.html
+++ b/content/media/test/test_progress.html
@@ -3,17 +3,16 @@
 <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);
 }
@@ -35,14 +34,17 @@ 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);
 }
 
-manager.runTests(gProgressTests, startTest);
-
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
+function beginTest() {
+  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,17 +4,16 @@
 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) {
@@ -51,16 +50,19 @@ 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);
 }
 
-manager.runTests(gSmallTests, startTest);
-
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
+function beginTest() {
+  manager.runTests(gSmallTests, startTest);
+}
 
 </script>
 </pre>
 
 </body>
 </html>
deleted file mode 100644
--- a/content/media/test/use_large_cache.js
+++ /dev/null
@@ -1,14 +0,0 @@
-(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,30 +19,16 @@ 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);
 }
@@ -52,40 +38,42 @@ 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(do_test);
+addLoadEvent(beginTest);
 
 </script>
 </pre>
 </body>
 </html>
-
--- a/toolkit/content/tests/widgets/Makefile.in
+++ b/toolkit/content/tests/widgets/Makefile.in
@@ -33,17 +33,16 @@ 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,29 +9,30 @@
 <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");
 
-  // Kick off test once audio has loaded.
-  audio.addEventListener("loadedmetadata", loadedmetadata, false);
-  audio.src = "audio.wav";
+  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";
+  }
 
   SimpleTest.waitForExplicitFinish();
-
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -9,17 +9,16 @@
 <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;
@@ -233,25 +232,28 @@ function maybeStartTest() {
     return;
 
   setTimeout("runTest(canplaythroughsavedevent);", 0);
 }
 
 var testnum = 1;
 var video = document.getElementById("video");
 
-// Kick off test once video has loaded.
-video.addEventListener("canplaythrough",  canplaythroughevent, false);
-window.addEventListener("load",  loadevent, false);
+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);
 
-// 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,13 +20,12 @@ 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,13 +20,12 @@ 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>
deleted file mode 100644
--- a/toolkit/content/tests/widgets/use_large_cache.js
+++ /dev/null
@@ -1,12 +0,0 @@
-(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,9 +82,11 @@ function runTest(index) {
   testCanvas.load(testCallback);
 
   var refCanvas = new RemoteCanvas(currentTest.ref, "ref-" + index);
   refCanvas.load(testCallback);
 }
 
 SimpleTest.waitForExplicitFinish();
 
-window.addEventListener("load", function() { runTest(0); }, true);
+window.addEventListener("load", function() {
+  SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, function(){ runTest(0); });
+}, true);