From d5569147a3f489325f7b37509c4cfc1b9a3f7637 Mon Sep 17 00:00:00 2001 From: "perkj@chromium.org" Date: Fri, 9 May 2014 10:32:50 +0000 Subject: Fix the video detector in webrtc/video_detector.js so it can be reused. NOTRY=True R=phoglund@chromium.org, tommi@chromium.org Review URL: https://codereview.chromium.org/274803004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269211 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/data/webrtc/video_detector.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'chrome/test/data/webrtc') 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; } -- cgit v1.1