@samitouri / QOS-React-2 / commits / 37bb9b76ab

remove old browser logger

Thomas Aylott committed Nov 11, 2013 at 15:07 UTC 37bb9b76aba0deb445874273b93955ffb1c18bf8
1 file changed -62
test/lib/testImageURL.browser.js deleted
-62
@@ -1,62 +0,0 @@
1 -testImageURL._recycle = function(img){
2 - console.log('_recycle', img);
3 - try {
4 - img.src = '';
5 - img.onload = img.onerror = null;
6 - } catch(e){}
7 - testImageURL._recycleBin.push(img);
8 -}
9 -testImageURL.getImage = function(callback){
10 - // if (!testImageURL._recycleBin) testImageURL._recycleBin = [new Image(),new Image(),new Image(),new Image()];
11 - // function get(){
12 - // if (testImageURL._recycleBin.length === 0) return setTimeout(get, 100);
13 - // callback(testImageURL._recycleBin.shift(), testImageURL._recycle);
14 - // }
15 - // get();
16 - callback(new Image(), function recycle(){});
17 -}
18 -
19 -testImageURL.defaultCallback = function(error, event){}
20 -
21 -function testImageURL(url, timeout, callback){
22 - if (typeof timeout == 'function'){
23 - callback = timeout;
24 - timeout = testImageURL.timeout;
25 - }
26 - if (typeof callback != 'function') callback = testImageURL.defaultCallback;
27 -
28 - testImageURL.getImage(function(img, done){
29 - function callbackWrapper(error, event){
30 - callbackWrapper = testImageURL.noop;
31 - testImageURL.running = (testImageURL.running || 0) - 1;
32 - clearTimeout(timer);
33 - done(img);
34 - img = url = timeout = null;
35 - callback(error, event);
36 - error = event = callback = null;
37 - }
38 -
39 - var timer = setTimeout(function(){callbackWrapper(Error('timeout'));}, timeout);
40 -
41 - try {
42 - img.onload = function(event){ callbackWrapper(null, event || window.event); };
43 - img.onerror = function(error){ callbackWrapper(error); };
44 - img.src = url;
45 - testImageURL.running = (testImageURL.running || 0) + 1;
46 -
47 - if (img.complete === true
48 - || img.readyState == 4
49 - || img.width > 0
50 - || img.height > 0
51 - || img.readyState == 'complete'
52 - ) callbackWrapper(null, null);
53 - }
54 - catch(error){
55 - callbackWrapper(error);
56 - }
57 - });
58 -}
59 -
60 -testImageURL.noop = function(){};
61 -
62 -testImageURL.timeout = 5000;