diff --git a/tests/assets/jquery.plugin.html2canvas.js b/tests/assets/jquery.plugin.html2canvas.js
deleted file mode 100644
index e8f79be..0000000
--- a/tests/assets/jquery.plugin.html2canvas.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * jQuery helper plugin for examples and tests
- */
-(function( $ ){
- $.fn.html2canvas = function(options) {
- if (options && options.profile && window.console && window.console.profile && window.location.search !== "?selenium2") {
- window.console.profile();
- }
- var date = new Date(),
- $message = null,
- timeoutTimer = false,
- timer = date.getTime();
- options = options || {};
-
- var promise = html2canvas(this, options);
- promise.catch(function(err) {
- console.log("html2canvas threw an error", err);
- });
-
- promise.then(function(canvas) {
- var $canvas = $(canvas),
- finishTime = new Date();
-
- if (options && options.profile && window.console && window.console.profileEnd) {
- window.console.profileEnd();
- }
- $canvas.addClass("html2canvas")
- .css({
- position: 'absolute',
- left: 0,
- top: 0
- }).appendTo(document.body);
-
- if (window.location.search !== "?selenium") {
- $canvas.siblings().toggle();
- $(window).click(function(){
- $canvas.toggle().siblings().toggle();
- throwMessage("Canvas Render " + ($canvas.is(':visible') ? "visible" : "hidden"));
- });
- throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)) + " ms
",4000);
- } else {
- $canvas.css('display', 'none');
- }
- // test if canvas is read-able
- try {
- $canvas[0].toDataURL();
- } catch(e) {
- if ($canvas[0].nodeName.toLowerCase() === "canvas") {
- // TODO, maybe add a bit less offensive way to present this, but still something that can easily be noticed
- window.alert("Canvas is tainted, unable to read data");
- }
- }
- });
-
- function throwMessage(msg,duration){
- window.clearTimeout(timeoutTimer);
- timeoutTimer = window.setTimeout(function(){
- $message.fadeOut(function(){
- $message.remove();
- $message = null;
- });
- },duration || 2000);
- if ($message)
- $message.remove();
- $message = $('
').html(msg).css({
- margin:0,
- padding:10,
- background: "#000",
- opacity:0.7,
- position:"fixed",
- top:10,
- right:10,
- fontFamily: 'Tahoma',
- color:'#fff',
- fontSize:12,
- borderRadius:12,
- width:'auto',
- height:'auto',
- textAlign:'center',
- textDecoration:'none',
- display:'none'
- }).appendTo(document.body).fadeIn();
- log(msg);
- }
- };
-})( jQuery );
diff --git a/tests/test.js b/tests/test.js
index a342dc3..65325aa 100644
--- a/tests/test.js
+++ b/tests/test.js
@@ -7,21 +7,100 @@
*/
var h2cSelector, h2cOptions;
(function(document, window) {
- var srcStart = '';
-
- document.write(srcStart + '/tests/assets/jquery-1.6.2.js' + scrEnd);
- document.write(srcStart + '/tests/assets/jquery.plugin.html2canvas.js' + scrEnd);
- var html2canvas = ['log', 'nodecontainer', 'stackingcontext', 'textcontainer', 'support', 'imagecontainer', 'dummyimagecontainer', 'proxyimagecontainer', 'gradientcontainer', 'lineargradientcontainer', 'webkitgradientcontainer',
- 'imageloader', 'nodeparser', 'font', 'fontmetrics', 'core', 'renderer', 'promise', 'renderers/canvas'], i;
- if (window.location.search === "?selenium") {
- document.write(srcStart + '/dist/html2canvas.js' + scrEnd);
- } else {
- for (i = 0; i < html2canvas.length; ++i) {
- document.write(srcStart + '/src/' + html2canvas[i] + '.js?' + Math.random() + scrEnd);
- }
+ function appendScript(src) {
+ document.write('');
}
+ var sources = ['log', 'nodecontainer', 'stackingcontext', 'textcontainer', 'support', 'imagecontainer', 'dummyimagecontainer', 'proxyimagecontainer', 'gradientcontainer',
+ 'lineargradientcontainer', 'webkitgradientcontainer', 'imageloader', 'nodeparser', 'font', 'fontmetrics', 'core', 'renderer', 'promise', 'renderers/canvas'];
+
+ ['/tests/assets/jquery-1.6.2'].concat(window.location.search === "?selenium" ? ['/dist/html2canvas'] : sources.map(function(src) { return '/src/' + src; })).forEach(appendScript);
+
window.onload = function() {
+ (function( $ ){
+ $.fn.html2canvas = function(options) {
+ if (options && options.profile && window.console && window.console.profile && window.location.search !== "?selenium2") {
+ window.console.profile();
+ }
+ var date = new Date(),
+ $message = null,
+ timeoutTimer = false,
+ timer = date.getTime();
+ options = options || {};
+
+ var promise = html2canvas(this, options);
+ promise['catch'](function(err) {
+ console.log("html2canvas threw an error", err);
+ });
+
+ promise.then(function(canvas) {
+ var $canvas = $(canvas),
+ finishTime = new Date();
+
+ if (options && options.profile && window.console && window.console.profileEnd) {
+ window.console.profileEnd();
+ }
+ $canvas.addClass("html2canvas")
+ .css({
+ position: 'absolute',
+ left: 0,
+ top: 0
+ }).appendTo(document.body);
+
+ if (window.location.search !== "?selenium") {
+ $canvas.siblings().toggle();
+ $(window).click(function(){
+ $canvas.toggle().siblings().toggle();
+ throwMessage("Canvas Render " + ($canvas.is(':visible') ? "visible" : "hidden"));
+ });
+ throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)) + " ms
",4000);
+ } else {
+ $canvas.css('display', 'none');
+ }
+ // test if canvas is read-able
+ try {
+ $canvas[0].toDataURL();
+ } catch(e) {
+ if ($canvas[0].nodeName.toLowerCase() === "canvas") {
+ // TODO, maybe add a bit less offensive way to present this, but still something that can easily be noticed
+ window.alert("Canvas is tainted, unable to read data");
+ }
+ }
+ });
+
+ function throwMessage(msg,duration){
+ window.clearTimeout(timeoutTimer);
+ timeoutTimer = window.setTimeout(function(){
+ $message.fadeOut(function(){
+ $message.remove();
+ $message = null;
+ });
+ },duration || 2000);
+ if ($message)
+ $message.remove();
+ $message = $('').html(msg).css({
+ margin:0,
+ padding:10,
+ background: "#000",
+ opacity:0.7,
+ position:"fixed",
+ top:10,
+ right:10,
+ fontFamily: 'Tahoma',
+ color:'#fff',
+ fontSize:12,
+ borderRadius:12,
+ width:'auto',
+ height:'auto',
+ textAlign:'center',
+ textDecoration:'none',
+ display:'none'
+ }).appendTo(document.body).fadeIn();
+ log(msg);
+ }
+ };
+ })(jQuery);
+
h2cSelector = [document.documentElement];
if (window.setUp) {
@@ -29,9 +108,7 @@ var h2cSelector, h2cOptions;
}
setTimeout(function() {
-
$(h2cSelector).html2canvas($.extend({
- flashcanvas: "../external/flashcanvas.min.js",
logging: true,
profile: true,
proxy: "http://html2canvas.appspot.com/query",