From cc0f868b9bd5d4dcc630c68d86e562fb339f3a5e Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 29 Nov 2011 12:17:09 +1300 Subject: [PATCH] Bug 687972 - Add some verification to MediaTestManager. r=roc --- content/media/test/manifest.js | 7 ++++++- content/media/test/test_playback.html | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/content/media/test/manifest.js b/content/media/test/manifest.js index 4106c9eb2a00..339cb903f974 100644 --- a/content/media/test/manifest.js +++ b/content/media/test/manifest.js @@ -341,6 +341,7 @@ function MediaTestManager() { this.startTest = startTest; this.tokens = []; this.isShutdown = false; + this.numTestsRunning = 0; // Always wait for explicit finish. SimpleTest.waitForExplicitFinish(); this.nextTest(); @@ -350,6 +351,8 @@ function MediaTestManager() { // Don't call more than once per token. this.started = function(token) { this.tokens.push(token); + this.numTestsRunning++; + is(this.numTestsRunning, this.tokens.length, "[started] Length of array should match number of running tests"); } // Registers that the test corresponding to 'token' has finished. Call when @@ -362,11 +365,13 @@ function MediaTestManager() { // Remove the element from the list of running tests. this.tokens.splice(i, 1); } + this.numTestsRunning--; + is(this.numTestsRunning, this.tokens.length, "[finished] Length of array should match number of running tests"); if (this.tokens.length < PARALLEL_TESTS) { this.nextTest(); } } - + // Starts the next batch of tests, or finishes if they're all done. // Don't call this directly, call finished(token) when you're done. this.nextTest = function() { diff --git a/content/media/test/test_playback.html b/content/media/test/test_playback.html index 9d8ee78fa904..7aa363d59eee 100644 --- a/content/media/test/test_playback.html +++ b/content/media/test/test_playback.html @@ -35,9 +35,9 @@ function startTest(test, token) { is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState"); ok(v.readyState != v.NETWORK_LOADED, test.name + " shouldn't report NETWORK_LOADED"); ok(v.ended, test.name + " checking playback has ended"); - if (v.ended && v.seenSuspend) { - if (v.parentNode) - v.parentNode.removeChild(v); + if (v.ended && v.seenSuspend && !v.finished) { + v.finished = true; + v.parentNode.removeChild(v); manager.finished(v.token); } }}(test, v); @@ -48,9 +48,9 @@ function startTest(test, token) { v.seenSuspend = true; ok(true, test.name + " got suspend"); - if (v.ended && v.seenSuspend) { - if (v.parentNode) - v.parentNode.removeChild(v); + if (v.ended && !v.finished) { + v.finished = true; + v.parentNode.removeChild(v); manager.finished(v.token); } }}(test, v);