From 8958797f0ac8cc3ef17c916864cd7301803e4d9b Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 3 Nov 2014 18:17:00 +0100 Subject: [PATCH] Bug 758476 - fix test_play_twice.html. r=cabjir --- dom/media/test/mochitest.ini | 4 +-- dom/media/test/test_play_twice.html | 38 ++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/dom/media/test/mochitest.ini b/dom/media/test/mochitest.ini index d58679ddb432..c75f1fb7cd0f 100644 --- a/dom/media/test/mochitest.ini +++ b/dom/media/test/mochitest.ini @@ -436,8 +436,8 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439 [test_play_events_2.html] skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439 [test_play_twice.html] -# Seamonkey: Bug 598252, B2G: Bug 982100, Android: Bug 758476, bug 981086 -skip-if = appname == "seamonkey" || toolkit == 'gonk' || toolkit == 'android' +# Seamonkey: Bug 598252 +skip-if = appname == "seamonkey" [test_playback.html] skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439 [test_playback_errors.html] diff --git a/dom/media/test/test_play_twice.html b/dom/media/test/test_play_twice.html index 61e46327e1e0..a1dd07e67c86 100644 --- a/dom/media/test/test_play_twice.html +++ b/dom/media/test/test_play_twice.html @@ -14,51 +14,67 @@ var manager = new MediaTestManager; function startTest(test, token) { var v = document.createElement('video'); - v.preload = "metadata"; v.token = token; manager.started(token); v.src = test.name; v.name = test.name; v.playingCount = 0; + v._playedOnce = false; + var check = function(test, v) { return function() { checkMetadata(test.name, v, test); }}(test, v); + var noLoad = function(test, v) { return function() { ok(false, test.name + " should not fire 'load' event"); }}(test, v); + + function finish(v) { + removeNodeAndSource(v); + manager.finished(v.token); + } + + function mayFinish(v) { + if (v.seenEnded && v.seenSuspend) { + finish(v); + } + } + var checkEnded = function(test, v) { return function() { if (test.duration) { ok(Math.abs(v.currentTime - test.duration) < 0.1, test.name + " current time at end: " + v.currentTime); } + 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"); ok(v.playingCount > 0, "Expect at least one playing event"); v.playingCount = 0; - if (v._playedOnce && v.seenSuspend) { - v.parentNode.removeChild(v); - manager.finished(v.token); + + if (v._playedOnce) { + v.seenEnded = true; + mayFinish(v); } else { v._playedOnce = true; v.play(); } }}(test, v); + var checkSuspended = function(test, v) { return function() { - if (v.seenSuspend) + if (v.seenSuspend) { return; + } v.seenSuspend = true; ok(true, test.name + " got suspend"); - if (v._playedOnce && v.seenSuspend) { - v.parentNode.removeChild(v); - manager.finished(v.token); - } + mayFinish(v); }}(test, v); + var checkPlaying = function(test, v) { return function() { is(test.name, v.name, "Should be testing file we think we're testing..."); v.playingCount++; }}(test, v); + v.addEventListener("load", noLoad, false); v.addEventListener("loadedmetadata", check, false); v.addEventListener("playing", checkPlaying, false); @@ -66,7 +82,7 @@ function startTest(test, token) { // We should get "ended" and "suspend" events for every resource v.addEventListener("ended", checkEnded, false); v.addEventListener("suspend", checkSuspended, false); - + document.body.appendChild(v); v.play(); }