diff options
author | perkj@chromium.org <perkj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-09 10:32:50 +0000 |
---|---|---|
committer | perkj@chromium.org <perkj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-09 10:32:50 +0000 |
commit | d5569147a3f489325f7b37509c4cfc1b9a3f7637 (patch) | |
tree | 8c1ea3b3ee9654a192b90e32e1a7ae986efbd1f3 /chrome/test/data/webrtc | |
parent | 1ae98f9a589a0aefd5a33f21fa443711a87db5fd (diff) | |
download | chromium_src-d5569147a3f489325f7b37509c4cfc1b9a3f7637.zip chromium_src-d5569147a3f489325f7b37509c4cfc1b9a3f7637.tar.gz chromium_src-d5569147a3f489325f7b37509c4cfc1b9a3f7637.tar.bz2 |
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
Diffstat (limited to 'chrome/test/data/webrtc')
-rw-r--r-- | chrome/test/data/webrtc/video_detector.js | 9 |
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; } |