forked from niklasvh/html2canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrolling.html
More file actions
66 lines (63 loc) · 2.08 KB
/
Copy pathscrolling.html
File metadata and controls
66 lines (63 loc) · 2.08 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Scrolling tests</title>
<link rel="stylesheet" href="lib/mocha.css" />
<script src="../../dist/html2canvas.js"></script>
<script src="../assets/jquery-1.6.2.js"></script>
<script src="lib/expect.js"></script>
<script src="lib/mocha.js"></script>
</head>
<body>
<div id="mocha"></div>
<script>mocha.setup('bdd')</script>
<div style="height: 2200px;"></div>
<div style="height: 500px;background: green;"><a name="content">content</a></div>
<script>
describe("Scrolling", function() {
it("with random scroll", function (done) {
$(window).scrollTop(123);
setTimeout(function() {
html2canvas(document.body, {type: 'view'}).then(function () {
expect($(window).scrollTop()).to.equal(123);
done();
}).catch(function (error) {
done(error);
});
}, 0);
});
it("with url anchor", function (done) {
window.location.hash = "#content";
setTimeout(function() {
var top = $(window).scrollTop();
html2canvas(document.body, {type: 'view', removeContainer: false}).then(function () {
var currentTop = $(window).scrollTop();
window.location.hash = "";
expect(currentTop).to.be.greaterThan(1500);
if ((currentTop - top) !== 200) { // phantomjs issue
expect(currentTop).to.equal(top);
}
done();
}).catch(function (error) {
done(error);
});
}, 0);
});
});
after(function() {
if (history) {
history.pushState("", document.title, window.location.pathname + window.location.search);
}
});
mocha.checkLeaks();
mocha.globals(['jQuery']);
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
}
else {
mocha.run();
}
</script>
</body>
</html>