-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathdata-uri.js
49 lines (37 loc) · 1.1 KB
/
data-uri.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
describe('using data-uris as image sources', function() {
if( !document.addEventListener ){
return;
}
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
// using a data-uri, will fail on IE, it does not triggers onload
var fakeSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
var realSrc = '/test/fixtures/tiny.gif?'+(+new Date());
var test;
beforeEach(function() {
test = h.createTest({
tagName: 'img',
attributes: {
'id': 'data-uri',
src: fakeSrc,
'data-src': realSrc,
width: 10,
height: 10,
onload: 'lzld(this)'
}
});
h.insertTest(test);
});
it('src currently fake', function() {
assert(test.src.indexOf(fakeSrc) !== -1);
});
it('getAttribute still gives real src', function() {
assert.equal(realSrc, test.getAttribute('src'));
});
describe('after some scrolling', function() {
beforeEach(h.scroller(0, 50));
beforeEach(h.scroller(0, 0));
it('loads the image when visible for a while', h.eltLoaded('data-uri'));
});
});