mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Correctly render input[type="password"] value
This commit is contained in:
72
tests/mocha/password-rendering.html
Normal file
72
tests/mocha/password-rendering.html
Normal file
@ -0,0 +1,72 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Tests</title>
|
||||
<link rel="stylesheet" href="lib/mocha.css" />
|
||||
<script src="../../dist/html2canvas.js"></script>
|
||||
<script src="../../src/log.js"></script>
|
||||
<script src="../../src/renderer.js"></script>
|
||||
<script src="../../src/renderers/canvas.js"></script>
|
||||
<script src="../assets/jquery-1.6.2.js"></script>
|
||||
<script src="lib/expect.js"></script>
|
||||
<script src="lib/mocha.js"></script>
|
||||
<style>
|
||||
.block {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script>mocha.setup('bdd')</script>
|
||||
<div id="block1" class="block">
|
||||
<input type="text" value="text" />
|
||||
</div>
|
||||
<div id="block2" class="block">
|
||||
<input type="password" value="password" />
|
||||
</div>
|
||||
<div id="green-block"></div>
|
||||
<script>
|
||||
describe("Rendering input values", function() {
|
||||
it("uses default value for input[type='text']", function(done) {
|
||||
CanvasRenderer.prototype.text = function(text) {
|
||||
expect(text).to.equal('text');
|
||||
};
|
||||
html2canvas(document.querySelector("#block1"), {renderer: CanvasRenderer, strict: true}).then(function(canvas) {
|
||||
expect(canvas.width).to.equal(200);
|
||||
expect(canvas.height).to.equal(200);
|
||||
done();
|
||||
}).catch(function(error) {
|
||||
done(error);
|
||||
});
|
||||
});
|
||||
|
||||
it("uses transformed value for input[type='password']", function(done) {
|
||||
var count = 0;
|
||||
CanvasRenderer.prototype.text = function(text) {
|
||||
expect(text).to.equal('•');
|
||||
count++;
|
||||
};
|
||||
html2canvas(document.querySelector("#block2"), {renderer: CanvasRenderer, strict: true}).then(function(canvas) {
|
||||
expect(canvas.width).to.equal(200);
|
||||
expect(canvas.height).to.equal(200);
|
||||
expect(count).to.equal("password".length);
|
||||
done();
|
||||
}).catch(function(error) {
|
||||
done(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
mocha.checkLeaks();
|
||||
mocha.globals(['jQuery']);
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
}
|
||||
else {
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user