From a8b746d049fbbd152e7d866227748ce02e3a7800 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Wed, 2 Nov 2016 16:56:38 +0800 Subject: [PATCH] Bug 1318982 - Enable dormant for most media mochitests. r=jya MozReview-Commit-ID: 7AXEhCmFUeR --HG-- extra : rebase_source : fa42b09dda75c3385edc6f7decc240816195722b extra : intermediate-source : 3376be75b913bbc3bd0920828f9e756982e9cac3 extra : source : ffee549ec036bc3ec1b9b1bccb26314c5adb5096 --- dom/media/mediasource/test/mediasource.js | 14 ++-- .../mediasource/test/test_Eviction_mp4.html | 70 +++++++++---------- .../mediasource/test/test_PlayEvents.html | 3 + .../test/test_ResumeAfterClearing_mp4.html | 3 + testing/profiles/prefs_general.js | 2 +- 5 files changed, 52 insertions(+), 40 deletions(-) diff --git a/dom/media/mediasource/test/mediasource.js b/dom/media/mediasource/test/mediasource.js index 6a464096a33d..760de353f0f9 100644 --- a/dom/media/mediasource/test/mediasource.js +++ b/dom/media/mediasource/test/mediasource.js @@ -1,5 +1,14 @@ // Helpers for Media Source Extensions tests +var gMSETestPrefs = [ + [ "media.mediasource.enabled", true ] +]; + +// Called before runWithMSE() to set the prefs before running MSE tests. +function addMSEPrefs(...prefs) { + gMSETestPrefs = gMSETestPrefs.concat(prefs); +} + function runWithMSE(testFunction) { function bootstrapTest() { var ms = new MediaSource(); @@ -17,10 +26,7 @@ function runWithMSE(testFunction) { } addLoadEvent(function () { - SpecialPowers.pushPrefEnv({"set": [ - [ "media.mediasource.enabled", true ], - ]}, - bootstrapTest); + SpecialPowers.pushPrefEnv({"set": gMSETestPrefs}, bootstrapTest); }); } diff --git a/dom/media/mediasource/test/test_Eviction_mp4.html b/dom/media/mediasource/test/test_Eviction_mp4.html index c702cc3bb262..8c377e5c2ddc 100644 --- a/dom/media/mediasource/test/test_Eviction_mp4.html +++ b/dom/media/mediasource/test/test_Eviction_mp4.html @@ -31,46 +31,46 @@ function fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCal }); } +addMSEPrefs( + ["media.mediasource.eviction_threshold.audio", 524288], + ["media.dormant-on-pause-timeout-ms", -1] // FIXME: bug 1319292 +); + runWithMSE(function(ms, el) { el.controls = true; once(ms, 'sourceopen').then(function() { ok(true, "Receive a sourceopen event"); - SpecialPowers.pushPrefEnv({ - "set": [ - ["media.mediasource.eviction_threshold.audio", 524288], - ] - }, function() { - let audiosb = ms.addSourceBuffer("audio/mp4"); - audiosb.mode = "sequence"; - fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4') - .then(function() { - fetchWithXHR('bipbop/bipbop_audio1.m4s', function(audioBuffer) { - fillUpSourceBuffer(audiosb, - function() { // doAppendDataFunc - audiosb.appendBuffer(audioBuffer); - }, - function(ex) { // onCaughtExceptionCallback - is(ex.name, 'QuotaExceededError', "QuotaExceededError thrown"); - is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range"); - let seekTime = audiosb.buffered.end(0) / 2; - el.currentTime = seekTime; - once(el, 'seeked', () => { - is(el.currentTime, seekTime, "correctly seeked to " + seekTime); - try { - audiosb.appendBuffer(audioBuffer); - } catch(ex) { - ok(false, "Shouldn't throw another time when data can be evicted"); - el.mozDumpDebugInfo(); - SimpleTest.finish(); - return; - } - once(audiosb, 'update', () => { - ok(true, "appendBuffer succeeded"); - SimpleTest.finish(); - }); + let audiosb = ms.addSourceBuffer("audio/mp4"); + audiosb.mode = "sequence"; + fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4') + .then(function() { + fetchWithXHR('bipbop/bipbop_audio1.m4s', function(audioBuffer) { + fillUpSourceBuffer(audiosb, + function() { // doAppendDataFunc + audiosb.appendBuffer(audioBuffer); + }, + function(ex) { // onCaughtExceptionCallback + is(ex.name, 'QuotaExceededError', "QuotaExceededError thrown"); + is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range"); + let seekTime = audiosb.buffered.end(0) / 2; + el.currentTime = seekTime; + once(el, 'seeked', () => { + dump("dump: seeked to " + seekTime); + is(el.currentTime, seekTime, "correctly seeked to " + seekTime); + try { + audiosb.appendBuffer(audioBuffer); + } catch(ex) { + ok(false, "Shouldn't throw another time when data can be evicted"); + el.mozDumpDebugInfo(); + SimpleTest.finish(); + return; + } + once(audiosb, 'update', () => { + ok(true, "appendBuffer succeeded"); + SimpleTest.finish(); }); - }); - }); + }); + }); }); }); }); diff --git a/dom/media/mediasource/test/test_PlayEvents.html b/dom/media/mediasource/test/test_PlayEvents.html index a390ae247b7f..bdc0b71b9f09 100644 --- a/dom/media/mediasource/test/test_PlayEvents.html +++ b/dom/media/mediasource/test/test_PlayEvents.html @@ -21,6 +21,9 @@ SimpleTest.waitForExplicitFinish(); // 6. Add 1.6s of data once video element fired waiting, that canplay is fired once readyState is HAVE_FUTURE_DATA. // 7. Finally load data to the end and ensure that canplaythrough is fired and that readyState is now HAVE_ENOUGH_DATA +// FIXME: bug 1319293 +addMSEPrefs(["media.dormant-on-pause-timeout-ms", -1]); + runWithMSE(function(ms, el) { el.controls = true; once(ms, 'sourceopen').then(function() { diff --git a/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html b/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html index b6769cb1b441..45bf54d60df8 100644 --- a/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html +++ b/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html @@ -11,6 +11,9 @@ SimpleTest.waitForExplicitFinish(); +// FIXME: bug 1319295 +addMSEPrefs(["media.dormant-on-pause-timeout-ms", -1]); + var receivedSourceOpen = false; runWithMSE(function(ms, v) { ms.addEventListener("sourceopen", function() { diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index 40163f581a2d..18646bc803e4 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -44,7 +44,7 @@ user_pref("media.preload.auto", 3); // auto = enough user_pref("media.cache_size", 1000); user_pref("media.volume_scale", "0.01"); user_pref("media.test.dumpDebugInfo", true); -user_pref("media.dormant-on-pause-timeout-ms", -1); // Disable dormant for it breaks some tests. +user_pref("media.dormant-on-pause-timeout-ms", 0); // Enter dormant immediately without waiting for timeout. user_pref("security.warn_viewing_mixed", false); user_pref("app.update.enabled", false); user_pref("app.update.staging.enabled", false);