mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Factor out more MSE test setup to the helper function. No bug. DONTBUILD
This commit is contained in:
parent
68155808a8
commit
a484227d25
@ -1,20 +1,34 @@
|
||||
// Helpers for Media Source Extensions tests
|
||||
|
||||
function runWithMSE(testFunction) {
|
||||
addLoadEvent(() => SpecialPowers.pushPrefEnv({"set": [[ "media.mediasource.enabled", true ]]}, testFunction));
|
||||
function bootstrapTest() {
|
||||
var ms = new MediaSource();
|
||||
|
||||
var el = document.createElement("video");
|
||||
el.src = URL.createObjectURL(ms);
|
||||
el.preload = "auto";
|
||||
|
||||
document.body.appendChild(el);
|
||||
SimpleTest.registerCleanupFunction(function () {
|
||||
el.parentNode.removeChild(el);
|
||||
});
|
||||
|
||||
testFunction(ms, el);
|
||||
}
|
||||
|
||||
addLoadEvent(function () {
|
||||
SpecialPowers.pushPrefEnv({"set": [[ "media.mediasource.enabled", true ]]},
|
||||
bootstrapTest);
|
||||
});
|
||||
}
|
||||
|
||||
function fetchWithXHR(uri, onLoadFunction) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", uri, true);
|
||||
xhr.responseType = "blob";
|
||||
xhr.addEventListener("load", function (e) {
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.addEventListener("load", function () {
|
||||
is(xhr.status, 200, "fetchWithXHR load uri='" + uri + "' status=" + xhr.status);
|
||||
var rdr = new FileReader();
|
||||
rdr.addEventListener("load", function (e) {
|
||||
onLoadFunction(e.target.result);
|
||||
});
|
||||
rdr.readAsArrayBuffer(e.target.response);
|
||||
onLoadFunction(xhr.response);
|
||||
});
|
||||
xhr.send();
|
||||
};
|
||||
|
@ -12,14 +12,7 @@
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runWithMSE(function () {
|
||||
var ms = new MediaSource();
|
||||
|
||||
var v = document.createElement("video");
|
||||
v.preload = "auto";
|
||||
v.src = URL.createObjectURL(ms);
|
||||
document.body.appendChild(v);
|
||||
|
||||
runWithMSE(function (ms, v) {
|
||||
ms.addEventListener("sourceopen", function () {
|
||||
var sb = ms.addSourceBuffer("video/webm");
|
||||
|
||||
@ -51,7 +44,6 @@ runWithMSE(function () {
|
||||
v.addEventListener("seeked", function () {
|
||||
ok(wasSeeking, "Received expected seeking and seeked events");
|
||||
is(v.currentTime, target, "Video currentTime not at target");
|
||||
v.parentNode.removeChild(v);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
@ -12,14 +12,7 @@
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runWithMSE(function () {
|
||||
var ms = new MediaSource();
|
||||
|
||||
var v = document.createElement("video");
|
||||
v.preload = "auto";
|
||||
v.src = URL.createObjectURL(ms);
|
||||
document.body.appendChild(v);
|
||||
|
||||
runWithMSE(function (ms, v) {
|
||||
ms.addEventListener("sourceopen", function () {
|
||||
var sb = ms.addSourceBuffer("video/webm");
|
||||
|
||||
@ -66,7 +59,6 @@ runWithMSE(function () {
|
||||
if (target) {
|
||||
v.currentTime = target.currentTime;
|
||||
} else {
|
||||
v.parentNode.removeChild(v);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
});
|
||||
|
@ -12,14 +12,7 @@
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runWithMSE(function () {
|
||||
var ms = new MediaSource();
|
||||
|
||||
var v = document.createElement("video");
|
||||
v.preload = "auto";
|
||||
v.src = URL.createObjectURL(ms);
|
||||
document.body.appendChild(v);
|
||||
|
||||
runWithMSE(function (ms, v) {
|
||||
ms.addEventListener("sourceopen", function () {
|
||||
var sb = ms.addSourceBuffer("video/webm");
|
||||
|
||||
@ -41,7 +34,6 @@ runWithMSE(function () {
|
||||
v.addEventListener("ended", function () {
|
||||
is(v.duration, 4, "Video has correct duration");
|
||||
is(v.currentTime, 4, "Video has played to end");
|
||||
v.parentNode.removeChild(v);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
@ -12,14 +12,7 @@
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runWithMSE(function () {
|
||||
var ms = new MediaSource();
|
||||
|
||||
var v = document.createElement("video");
|
||||
v.preload = "auto";
|
||||
v.src = URL.createObjectURL(ms);
|
||||
document.body.appendChild(v);
|
||||
|
||||
runWithMSE(function (ms, v) {
|
||||
ms.addEventListener("sourceopen", function () {
|
||||
var sb = ms.addSourceBuffer("video/webm");
|
||||
|
||||
@ -43,7 +36,6 @@ runWithMSE(function () {
|
||||
v.addEventListener("ended", function () {
|
||||
is(v.duration, 4, "Video has correct duration");
|
||||
is(v.currentTime, 4, "Video has played to end");
|
||||
v.parentNode.removeChild(v);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user