d20e600ea64be7a42de4cf63fe8c63e7e4831591.svn-base 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8">
  5. <title>Proxy tests</title>
  6. <link rel="stylesheet" href="lib/mocha.css" />
  7. <script src="../../node_modules/bluebird/js/browser/bluebird.js"></script>
  8. <script src="../assets/jquery-1.6.2.js"></script>
  9. <script src="lib/expect.js"></script>
  10. <script src="lib/mocha.js"></script>
  11. <style>
  12. #block {
  13. background: red;
  14. }
  15. #block.class {
  16. background: green;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div style="width: 200px; height:200px;" id="block"></div>
  22. <script src="../../dist/html2canvas.js"></script>
  23. <script src="clone.js"></script>
  24. <div id="mocha"></div>
  25. <script>mocha.setup('bdd')</script>
  26. <script>
  27. // https://github.com/niklasvh/html2canvas/issues/503
  28. describe("Document clone should not re-execute javascript", function() {
  29. it("with mutating className", function (done) {
  30. this.timeout(10000);
  31. html2canvas(document.querySelector("#block")).then(function (canvas) {
  32. expect(canvas.width).to.equal(200);
  33. expect(canvas.height).to.equal(200);
  34. validCanvasPixels(canvas);
  35. done();
  36. }).catch(function (error) {
  37. done(error);
  38. });
  39. });
  40. });
  41. function validCanvasPixels(canvas) {
  42. var ctx = canvas.getContext("2d");
  43. var data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
  44. for (var i = 0, len = data.length; i < len; i+=4) {
  45. if (data[i] !== 0 || data[i+1] !== 128 || data[i+2] !== 0 || data[i+3] !== 255) {
  46. expect().fail("Invalid canvas data");
  47. }
  48. }
  49. }
  50. mocha.checkLeaks();
  51. mocha.globals(['jQuery']);
  52. if (window.mochaPhantomJS) {
  53. mochaPhantomJS.run();
  54. }
  55. else {
  56. mocha.run();
  57. }
  58. mocha.suite.afterAll(function() {
  59. document.body.setAttribute('data-complete', 'true');
  60. });
  61. </script>
  62. </body>
  63. </html>