2014-11-29 22:04:35 +03:00
|
|
|
<!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>
|
2014-11-30 15:23:52 +03:00
|
|
|
<div style="height: 2200px;"></div>
|
2014-11-29 22:04:35 +03:00
|
|
|
<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();
|
2014-12-06 17:19:38 +03:00
|
|
|
html2canvas(document.body, {type: 'view', removeContainer: false}).then(function () {
|
2014-11-29 22:04:35 +03:00
|
|
|
var currentTop = $(window).scrollTop();
|
|
|
|
window.location.hash = "";
|
2014-11-30 15:23:52 +03:00
|
|
|
expect(currentTop).to.be.greaterThan(1500);
|
2014-12-06 17:19:38 +03:00
|
|
|
if ((currentTop - top) !== 200) { // phantomjs issue
|
|
|
|
expect(currentTop).to.equal(top);
|
|
|
|
}
|
2014-11-29 22:04:35 +03:00
|
|
|
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();
|
|
|
|
}
|
2015-01-18 15:31:53 +03:00
|
|
|
mocha.suite.afterAll(function() {
|
|
|
|
document.body.setAttribute('data-complete', 'true');
|
|
|
|
});
|
2014-11-29 22:04:35 +03:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|