summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/webrtc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/data/webrtc')
-rw-r--r--chrome/test/data/webrtc/video_detector.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/chrome/test/data/webrtc/video_detector.js b/chrome/test/data/webrtc/video_detector.js
index 3c10813..4c96610 100644
--- a/chrome/test/data/webrtc/video_detector.js
+++ b/chrome/test/data/webrtc/video_detector.js
@@ -7,6 +7,7 @@
// This file requires the functions defined in test_functions.js.
var gFingerprints = [];
+var gDetectorInterval = null;
// Public interface.
@@ -28,11 +29,15 @@ function startDetection(videoElementId, width, height) {
if (!video)
throw failTest('Could not find video element with id ' + videoElementId);
+ if (gDetectorInterval)
+ throw failTest('Detector is already running.');
+
var NUM_FINGERPRINTS_TO_SAVE = 5;
var canvas = document.createElement('canvas');
canvas.style.display = 'none';
- setInterval(function() {
+ gFingerprints = [];
+ gDetectorInterval = setInterval(function() {
var context = canvas.getContext('2d');
if (video.videoWidth == 0)
return; // The video element isn't playing anything.
@@ -61,6 +66,8 @@ function isVideoPlaying() {
try {
if (gFingerprints.length > 1) {
if (!allElementsRoughlyEqualTo_(gFingerprints, gFingerprints[0])) {
+ clearInterval(gDetectorInterval);
+ gDetectorInterval = null;
returnToTest('video-playing');
return;
}