Bug 972826 - Reset 'src' to force releasing h264 decoder so that the cloned <video> can play gizmo.mp4. r=cajbir, a=test-only
--- a/content/media/test/test_load_same_resource.html
+++ b/content/media/test/test_load_same_resource.html
@@ -18,32 +18,43 @@ function cloneLoaded(event) {
var e = event.target;
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
"Clone " + e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
}
e.removeEventListener("loadeddata", cloneLoaded, false);
-
+ removeNodeAndSource(e);
manager.finished(e.token);
}
function tryClone(event) {
var e = event.target;
var clone = e.cloneNode(false);
clone.token = e.token;
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
clone._expectedDuration = e._expectedDuration;
}
clone.addEventListener("loadeddata", cloneLoaded, false);
+ clone.onloadstart = function(evt) {
+ info("cloned " + evt.target.token + " start loading.");
+ evt.target.onloadstart = null;
+ // 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);
+ }
e.removeEventListener("loadeddata", tryClone, false);
}
// 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