From a2070ed13768eca9697938faba07e9f7c0322233 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 16 Sep 2014 19:35:00 +1200 Subject: [PATCH] Bug 1059265 - reduce number of concurrent playback and active cubeb streams to avoid hitting bug 847903. --- content/media/test/reactivate_helper.html | 32 +++++++++++++----- content/media/test/test_reactivate.html | 41 ++++++++++------------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/content/media/test/reactivate_helper.html b/content/media/test/reactivate_helper.html index 8e995bec60c2..af4c8b9ca3b1 100644 --- a/content/media/test/reactivate_helper.html +++ b/content/media/test/reactivate_helper.html @@ -5,29 +5,45 @@ var loadsWaiting = 0; var elements = []; -function loadedData(event) { - parent.ok(elements.indexOf(event.target) == -1, "Element already loaded: " + event.target.currentSrc); - - elements.push(event.target); - +function checkAllLoaded() { --loadsWaiting; - parent.ok(true, "Loaded " + event.target.currentSrc); if (loadsWaiting == 0) { parent.loadedAll(elements); } } +function loadedData(event) { + var e = event.target; + parent.ok(elements.indexOf(e) == -1, "Element already loaded: " + e._name); + parent.info("Loaded " + e._name); + elements.push(e); + // Reset "onerror" handler to avoid triggering another error in removeNodeAndSource(). + e.onerror = null; + checkAllLoaded(); + +} + +function error(event) { + var e = event.target; + parent.info("Error " + e._name); + // Don't wait for the element encounting errors. + checkAllLoaded(); +} + for (var i = 0; i < parent.gSmallTests.length; ++i) { var test = parent.gSmallTests[i]; var elemType = /^audio/.test(test.type) ? "audio" : "video"; // Associate these elements with the subframe's document var e = document.createElement(elemType); - e.preload = "auto"; + e.preload = "metadata"; if (e.canPlayType(test.type)) { e.src = test.name; - e.addEventListener("loadeddata", loadedData, false); + e._name = test.name; + e.onloadeddata = loadedData; + e.onerror = error; e.load(); ++loadsWaiting; + parent.info("Loading " + e._name); } } diff --git a/content/media/test/test_reactivate.html b/content/media/test/test_reactivate.html index 3277df004641..ef1b47447208 100644 --- a/content/media/test/test_reactivate.html +++ b/content/media/test/test_reactivate.html @@ -13,28 +13,27 @@