Bug 1376449 - Robustify startDrawing to prevent calling callback function after stop() has been called. r=pehrsons
MozReview-Commit-ID: 5vPtTHBGJhN
--- a/dom/canvas/test/captureStream_common.js
+++ b/dom/canvas/test/captureStream_common.js
@@ -37,18 +37,19 @@ CaptureStreamTestHelper.prototype = {
/*
* Perform the drawing operation on each animation frame until stop is called
* on the returned object.
*/
startDrawing: function (f) {
var stop = false;
var draw = () => {
+ if (stop) { return; }
f();
- if (!stop) { window.requestAnimationFrame(draw); }
+ window.requestAnimationFrame(draw);
};
draw();
return { stop: () => stop = true };
},
/* Request a frame from the stream played by |video|. */
requestFrame: function (video) {
info("Requesting frame from " + video.id);