clone.addEventListener("loadeddata", cloneLoaded, {once: true});
clone.addEventListener("loadstart", function(evt) {
info(`${evt.target.token} starts loading.`);
// Since there is only one H264 decoder instance, we have to delete the
// decoder of the original element for the cloned element to load. However,
// we can't delete the decoder too early otherwise cloning decoder will
// fail to kick in. We wait for 'loadstart' event of the cloned element to
// know when the decoder is already cloned and we can delete the decoder of
// the original element.
removeNodeAndSource(e);
}, {once: true});
}
// This test checks that loading the same URI twice in different elements at the same time
// uses the same resource without doing another network fetch. One of the gCloneTests
// uses dynamic_resource.sjs to return one resource on the first fetch and a different resource
// on the second fetch. These resources have different lengths, so if the cloned element
// does a network fetch it will get a resource with the wrong length and we get a test
// failure.
async function initTest(test, token) { var e = document.createElement("video");
e.preload = "auto";
e.src = test.name;
e._expectedDuration = test.duration;
ok(true, `Trying to load ${test.name}, duration=${test.duration}`);
e.token = token;
manager.started(token);
// Since 320x240.webm is less than 32KB, we need to wait for the
// 'suspend' event to ensure the partial block is flushed to the cache
// otherwise the cloned resource will create a new channel when it
// has no data to read at position 0. The new channel will download
// a different file than the original resource and fail the duration
// test.
let p1 = once(e, "loadeddata");
let p2 = once(e, "suspend");
await p1;
await p2;
tryClone(e);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.