Bug 902686 - Change manifest.js to use SpecialPowers.pushPrefEnv. r=edwin

This commit is contained in:
Martijn Wargers 2014-07-14 12:18:16 +02:00
parent 1621ba32cf
commit 60bd3cd7ca
6 changed files with 22 additions and 55 deletions

View File

@ -841,6 +841,8 @@ var PARALLEL_TESTS = 2;
// conditions that might not otherwise be encountered on the test data.
var gTestPrefs = [
['media.recorder.max_memory', 1024],
["media.preload.default", 2], // default preload = metadata
["media.preload.auto", 3] // auto preload = enough
];
// When true, we'll loop forever on whatever test we run. Use this to debug
@ -992,44 +994,12 @@ function mediaTestCleanup(callback) {
SpecialPowers.exactGC(window, cb);
}
(function() {
SimpleTest.requestFlakyTimeout("untriaged");
function setMediaTestsPrefs(callback, extraPrefs) {
var prefs = gTestPrefs;
if (extraPrefs) {
prefs = prefs.concat(extraPrefs);
}
SpecialPowers.pushPrefEnv({"set": prefs}, callback);
}
// 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 oldAppleMedia = undefined;
var oldGStreamer = undefined;
var oldOpus = undefined;
try { oldAppleMedia = SpecialPowers.getBoolPref("media.apple.mp3.enabled"); } catch(ex) { }
try { oldGStreamer = SpecialPowers.getBoolPref("media.gstreamer.enabled"); } catch(ex) { }
try { oldDefault = SpecialPowers.getIntPref("media.preload.default"); } catch(ex) { }
try { oldAuto = SpecialPowers.getIntPref("media.preload.auto"); } catch(ex) { }
try { oldOpus = SpecialPowers.getBoolPref("media.opus.enabled"); } catch(ex) { }
SpecialPowers.setIntPref("media.preload.default", 2); // preload_metadata
SpecialPowers.setIntPref("media.preload.auto", 3); // preload_enough
// test opus playback iff the pref exists
if (oldOpus !== undefined)
SpecialPowers.setBoolPref("media.opus.enabled", true);
if (oldGStreamer !== undefined)
SpecialPowers.setBoolPref("media.gstreamer.enabled", true);
if (oldAppleMedia !== undefined)
SpecialPowers.setBoolPref("media.apple.mp3.enabled", true);
window.addEventListener("unload", function() {
if (oldGStreamer !== undefined)
SpecialPowers.setBoolPref("media.gstreamer.enabled", oldGStreamer);
if (oldAppleMedia !== undefined)
SpecialPowers.setBoolPref("media.apple.mp3.enabled", oldAppleMedia);
SpecialPowers.setIntPref("media.preload.default", oldDefault);
SpecialPowers.setIntPref("media.preload.auto", oldAuto);
if (oldOpus !== undefined)
SpecialPowers.setBoolPref("media.opus.enabled", oldOpus);
}, false);
})();
SimpleTest.requestFlakyTimeout("untriaged");

View File

@ -28,7 +28,9 @@ function done() {
SimpleTest.finish();
}
addLoadEvent(run);
addLoadEvent(function() {
setMediaTestsPrefs(run);
});
SimpleTest.waitForExplicitFinish();

View File

@ -57,7 +57,7 @@ function loadStart(evt) {
// Create all video objects.
for (var i=0; i<g404Tests.length; ++i) {
var v = document.createElement("video");
v.preload = "auto";
v.preload = "metadata";
var test = g404Tests[i];
if (!v.canPlayType(test.type)) {
continue;

View File

@ -62,7 +62,7 @@ var gMedia = null;
function createMedia(tag) {
gMedia = document.createElement(tag);
gMedia.preload = "auto";
gMedia.preload = "metadata";
for (var i=0; i<gEventTypes.length; i++) {
gMedia.addEventListener(gEventTypes[i], listener, false);
}

View File

@ -14,7 +14,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=715469
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=715469">Mozilla Bug 715469</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
@ -32,18 +31,14 @@ function start() {
SimpleTest.waitForExplicitFinish();
var v = document.createElement("video");
v.src = resource.name;
v.addEventListener("loadeddata", function(){v.play();}, false);
v.controls = "true";
v.addEventListener("load",
function(){
gotLoadEvent = true;
},
false);
v.addEventListener("load", function() {
gotLoadEvent = true;
}, false);
v.addEventListener("ended", finished, false);
document.body.appendChild(v);
v.play();
}
}
@ -52,7 +47,6 @@ function finished() {
SimpleTest.finish();
}
</script>
</pre>
</body>

View File

@ -30,6 +30,7 @@ SimpleTest.waitForExplicitFinish();
</script>
</pre>
<video id='v'
preload='metadata'
src='noContentLength.sjs'
onloadedmetadata='on_metadataloaded();'></video>
</body>