Bug 1295352 - Check that there is no active gUM after each runTest test. r=pehrsons

MozReview-Commit-ID: 4VVb2ZJWiCL

--HG--
extra : rebase_source : 80abc1cffeb8f6abe45ce88cc7aa55a3e7980b7b
extra : intermediate-source : 19d4e98a11915cd17c61b8563b7eb6a540d3e229
extra : source : dd574e92185152653dbf070d55bf93fb3e28edd6
This commit is contained in:
Jan-Ivar Bruaroey 2016-08-05 00:46:25 -04:00
Родитель 0701269a64
Коммит ef2e75bf5c
1 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -254,6 +254,23 @@ function createHTML(options) {
return scriptsReady.then(() => realCreateHTML(options));
}
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
// noGum - Helper to detect whether active guM tracks still exist.
//
// It relies on the fact that, by spec, device labels from enumerateDevices are
// only visible during active gum calls. They're also visible when persistent
// permissions are granted, so turn off media.navigator.permission.disabled
// (which is normally on otherwise in our tests). Lastly, we must turn on
// media.navigator.permission.fake otherwise fake devices don't count as active.
var noGum = () => pushPrefs(["media.navigator.permission.disabled", false],
["media.navigator.permission.fake", true])
.then(() => navigator.mediaDevices.enumerateDevices())
.then(([device]) => device &&
is(device.label, "", "Test must leave no active gUM streams behind."));
var runTest = testFunction => scriptsReady
.then(() => runTestWhenReady(testFunction))
.then(() => noGum())
.then(() => finish());