mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
Bug 1208373 - Check that we don't get "ended" event for tracks after calling stop(). r=jib
MozReview-Commit-ID: K9gOZtUNQ5K --HG-- extra : rebase_source : cfe14a021af54eb16fdded0e71e8332d0fcf1448 extra : source : 2996367191d23fd1aa4630d4a964b2577c7fbf8c
This commit is contained in:
parent
7d1a406c3f
commit
65f6569e63
@ -590,6 +590,28 @@ function createOneShotEventWrapper(wrapper, obj, event) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when `target` has raised an event with the
|
||||||
|
* given name. Cancel the returned promise by passing in a `cancelPromise` and
|
||||||
|
* resolve it.
|
||||||
|
*
|
||||||
|
* @param {object} target
|
||||||
|
* The target on which the event should occur.
|
||||||
|
* @param {string} name
|
||||||
|
* The name of the event that should occur.
|
||||||
|
* @param {promise} cancelPromise
|
||||||
|
* A promise that on resolving rejects the returned promise,
|
||||||
|
* so we can avoid logging results after a test has finished.
|
||||||
|
*/
|
||||||
|
function haveEvent(target, name, cancelPromise) {
|
||||||
|
var listener;
|
||||||
|
var p = Promise.race([
|
||||||
|
(cancelPromise || new Promise()).then(e => Promise.reject(e)),
|
||||||
|
new Promise(resolve => target.addEventListener(name, listener = resolve))
|
||||||
|
]);
|
||||||
|
p.then(() => target.removeEventListener(name, listener));
|
||||||
|
return p;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class executes a series of functions in a continuous sequence.
|
* This class executes a series of functions in a continuous sequence.
|
||||||
|
@ -55,8 +55,17 @@ MediaStreamPlayback.prototype = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO (bug 910249) Also check that all the tracks are local.
|
var noTrackEnded = Promise.all(this.mediaStream.getTracks().map(t => {
|
||||||
this.mediaStream.getTracks().forEach(t => t.stop());
|
let onNextLoop = wait(0);
|
||||||
|
let p = Promise.race([
|
||||||
|
onNextLoop,
|
||||||
|
haveEvent(t, "ended", onNextLoop)
|
||||||
|
.then(() => Promise.reject("Unexpected ended event for track " + t.id),
|
||||||
|
() => Promise.resolve())
|
||||||
|
]);
|
||||||
|
t.stop();
|
||||||
|
return p;
|
||||||
|
}));
|
||||||
|
|
||||||
// XXX (bug 1208316) When we implement MediaStream.active, do not stop
|
// XXX (bug 1208316) When we implement MediaStream.active, do not stop
|
||||||
// the stream. We just do it now so the media element will raise 'ended'.
|
// the stream. We just do it now so the media element will raise 'ended'.
|
||||||
@ -65,7 +74,8 @@ MediaStreamPlayback.prototype = {
|
|||||||
}
|
}
|
||||||
this.mediaStream.stop();
|
this.mediaStream.stop();
|
||||||
return timeout(waitForEnded(), ENDED_TIMEOUT_LENGTH, "ended event never fired")
|
return timeout(waitForEnded(), ENDED_TIMEOUT_LENGTH, "ended event never fired")
|
||||||
.then(() => ok(true, "ended event successfully fired"));
|
.then(() => ok(true, "ended event successfully fired"))
|
||||||
|
.then(() => noTrackEnded);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user