diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index b636649089d9..49f580f66680 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -118,7 +118,6 @@ MOCHITEST_FILES = \ 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 \ diff --git a/content/media/test/manifest.js b/content/media/test/manifest.js index 4c017cab7440..6da639281812 100644 --- a/content/media/test/manifest.js +++ b/content/media/test/manifest.js @@ -558,7 +558,8 @@ function MediaTestManager() { this.numTestsRunning = 0; // Always wait for explicit finish. SimpleTest.waitForExplicitFinish(); - this.nextTest(); + + SpecialPowers.pushPrefEnv({"set": [["media.preload.default", 2], ["media.preload.auto", 3], ["media.opus.enabled", true]]}, function(aThis) {aThis.nextTest();}(this)); } // Registers that the test corresponding to 'token' has been started. @@ -646,31 +647,3 @@ function mediaTestCleanup() { } 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); - })(); diff --git a/content/media/test/test_buffered.html b/content/media/test/test_buffered.html index 2c2ee0f1d5da..98ea36c9983f 100644 --- a/content/media/test/test_buffered.html +++ b/content/media/test/test_buffered.html @@ -8,7 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462957 - Mozilla Bug 462957 @@ -85,8 +84,11 @@ function startTest(test, token) { document.body.appendChild(v); } -manager.runTests(gSeekTests, startTest); - +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest); +function beginTest() { + manager.runTests(gSeekTests, startTest); +} diff --git a/content/media/test/test_bug493187.html b/content/media/test/test_bug493187.html index 25c27161f074..db9ce8ee8e80 100644 --- a/content/media/test/test_bug493187.html +++ b/content/media/test/test_bug493187.html @@ -8,7 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=493187 Bug 493187 - enter HAVE_FUTURE_DATA when seeking within buffered data even if new data isn't arriving - @@ -62,8 +61,11 @@ function startTest(test, token) { document.body.appendChild(v); } -manager.runTests(gSeekTests, startTest); - +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest); +function beginTest() { + manager.runTests(gSeekTests, startTest); +} diff --git a/content/media/test/test_can_play_type_mpeg.html b/content/media/test/test_can_play_type_mpeg.html index 1b310013519d..cd113704fc98 100644 --- a/content/media/test/test_can_play_type_mpeg.html +++ b/content/media/test/test_can_play_type_mpeg.html @@ -33,24 +33,17 @@ function IsWindows7() { } 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); diff --git a/content/media/test/test_closing_connections.html b/content/media/test/test_closing_connections.html index 89d483ed5e7e..a01fc139bec5 100644 --- a/content/media/test/test_closing_connections.html +++ b/content/media/test/test_closing_connections.html @@ -32,17 +32,20 @@ window.onload = function() { we've got the first frame. */ - 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"); } diff --git a/content/media/test/test_decode_error.html b/content/media/test/test_decode_error.html index 6263742b74f6..c7081a0db8be 100644 --- a/content/media/test/test_decode_error.html +++ b/content/media/test/test_decode_error.html @@ -4,7 +4,6 @@ Media test: unknown/invalid formats raise decode error - @@ -44,8 +43,11 @@ function startTest(test, token) { 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); +} diff --git a/content/media/test/test_preload_actions.html b/content/media/test/test_preload_actions.html index 09d31ce49f3a..b47c8e0b5f0c 100644 --- a/content/media/test/test_preload_actions.html +++ b/content/media/test/test_preload_actions.html @@ -8,7 +8,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=548523 - Mozilla Bug 548523 @@ -568,8 +567,11 @@ function startTest(test, 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); +} diff --git a/content/media/test/test_preload_suspend.html b/content/media/test/test_preload_suspend.html index 0738077e838b..fface25a656d 100644 --- a/content/media/test/test_preload_suspend.html +++ b/content/media/test/test_preload_suspend.html @@ -7,7 +7,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479863 Test for Bug 479863 - Mozilla Bug 479863 @@ -70,17 +69,21 @@ function suspended(event) { } 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; + } +} diff --git a/content/media/test/test_progress.html b/content/media/test/test_progress.html index 875b24d1cfa6..05bdd452fa21 100644 --- a/content/media/test/test_progress.html +++ b/content/media/test/test_progress.html @@ -8,7 +8,6 @@
-
 
 
diff --git a/content/media/test/test_video_to_canvas.html b/content/media/test/test_video_to_canvas.html index 4970aca66e24..b4a9f3752e98 100644 --- a/content/media/test/test_video_to_canvas.html +++ b/content/media/test/test_video_to_canvas.html @@ -9,7 +9,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=486646 - @@ -56,8 +55,11 @@ function startTest(test, token) { document.body.appendChild(v); } -manager.runTests(gSmallTests, startTest); - +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest); +function beginTest() { + manager.runTests(gSmallTests, startTest); +} diff --git a/content/media/test/use_large_cache.js b/content/media/test/use_large_cache.js deleted file mode 100644 index 1b53240c114d..000000000000 --- 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); - })(); diff --git a/layout/forms/test/test_bug411236.html b/layout/forms/test/test_bug411236.html index e545a3cadc5d..e5d0ebd60f28 100644 --- a/layout/forms/test/test_bug411236.html +++ b/layout/forms/test/test_bug411236.html @@ -24,20 +24,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=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. @@ -57,7 +43,6 @@ function test() { if (i >= 100) { ok(false, "Couldn't find an input element!"); - setOrRestoreTabFocus(0); SimpleTest.finish(); return; } @@ -70,22 +55,25 @@ function test() { 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); - diff --git a/toolkit/content/tests/widgets/Makefile.in b/toolkit/content/tests/widgets/Makefile.in index 0036e9b7e314..00bf3b1d07cc 100644 --- a/toolkit/content/tests/widgets/Makefile.in +++ b/toolkit/content/tests/widgets/Makefile.in @@ -38,7 +38,6 @@ MOCHITEST_FILES = \ 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 \ diff --git a/toolkit/content/tests/widgets/test_audiocontrols_dimensions.html b/toolkit/content/tests/widgets/test_audiocontrols_dimensions.html index ec9640e90b4d..cf832a0a4b1c 100644 --- a/toolkit/content/tests/widgets/test_audiocontrols_dimensions.html +++ b/toolkit/content/tests/widgets/test_audiocontrols_dimensions.html @@ -14,7 +14,6 @@
-
 
 
diff --git a/toolkit/content/tests/widgets/test_videocontrols.html b/toolkit/content/tests/widgets/test_videocontrols.html index c1114e7a6fe1..cba7250f1a76 100644 --- a/toolkit/content/tests/widgets/test_videocontrols.html +++ b/toolkit/content/tests/widgets/test_videocontrols.html @@ -14,7 +14,6 @@
-
 
-
 
 
diff --git a/toolkit/content/tests/widgets/test_videocontrols_video_direction.html b/toolkit/content/tests/widgets/test_videocontrols_video_direction.html index f457a0455a34..54e0d5e72242 100644 --- a/toolkit/content/tests/widgets/test_videocontrols_video_direction.html +++ b/toolkit/content/tests/widgets/test_videocontrols_video_direction.html @@ -25,7 +25,6 @@ var tests = [ ]; - diff --git a/toolkit/content/tests/widgets/use_large_cache.js b/toolkit/content/tests/widgets/use_large_cache.js deleted file mode 100644 index 37b4b0dabfd9..000000000000 --- 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); - })(); diff --git a/toolkit/content/tests/widgets/videocontrols_direction_test.js b/toolkit/content/tests/widgets/videocontrols_direction_test.js index 0873154322bc..226aeca81c0c 100644 --- a/toolkit/content/tests/widgets/videocontrols_direction_test.js +++ b/toolkit/content/tests/widgets/videocontrols_direction_test.js @@ -87,4 +87,6 @@ function runTest(index) { SimpleTest.waitForExplicitFinish(); -window.addEventListener("load", function() { runTest(0); }, true); +window.addEventListener("load", function() { + SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, function(){ runTest(0); }); +}, true);