From bf4a3e54b335c922673c2a7c6e47d30fac9ada97 Mon Sep 17 00:00:00 2001 From: Kaku Kuo Date: Sun, 5 Jun 2016 22:15:49 +0800 Subject: [PATCH] Bug 1276272 - part 4 - modify the mochitest; r=jwwang MozReview-Commit-ID: 9DUpKblMbTz --HG-- extra : rebase_source : eb1c236b882f1b8fd40e441215c918cef585e2a9 --- dom/media/test/test_seekToNextFrame.html | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/dom/media/test/test_seekToNextFrame.html b/dom/media/test/test_seekToNextFrame.html index 4869b2f2dfed..b6869556c618 100644 --- a/dom/media/test/test_seekToNextFrame.html +++ b/dom/media/test/test_seekToNextFrame.html @@ -29,15 +29,28 @@ function startTest(test, token) { v.src = test.name; v.name = test.name; + function callSeekToNextFrame() { + v.seekToNextFrame().then( + () => { + ok(v.seenSeeking, "Should have already received seeking event.") + v.seenSeeking = false; + if (!v.seenEnded) + callSeekToNextFrame(); + }, + () => { + ok(false, "seekToNextFrame() failed."); + } + ); + } + var onLoadedmetadata = function(test, v) { return function() { - v.seekToNextFrame(); + callSeekToNextFrame(); }}(test, v); var finish = function() { v.finished = true; v.removeEventListener("loadedmetadata", onLoadedmetadata, false); v.removeEventListener("seeking", onSeeking, false); - v.removeEventListener("seeked", onSeeked, false); removeNodeAndSource(v); manager.finished(v.token); } @@ -52,15 +65,8 @@ function startTest(test, token) { v.seenSeeking = true; }}(test, v); - var onSeeked = function(test, v) { return function() { - ok(v.seenSeeking, "Should have already received seeking event.") - v.seenSeeking = false; - v.seekToNextFrame(); - }}(test, v); - v.addEventListener("loadedmetadata", onLoadedmetadata, false); v.addEventListener("seeking", onSeeking, false); - v.addEventListener("seeked", onSeeked, false); v.addEventListener("ended", onEnded, false); document.body.appendChild(v);