mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
"tests: moved Generate into own module; fixed QUnit messages"
This commit is contained in:
commit
9fc366b3f7
17
src/Core.js
17
src/Core.js
@ -75,7 +75,8 @@ _html2canvas.Util.getCSS = function (el, attribute) {
|
|||||||
|
|
||||||
// If we're not dealing with a regular pixel number
|
// If we're not dealing with a regular pixel number
|
||||||
// but a number that has a weird ending, we need to convert it to pixels
|
// but a number that has a weird ending, we need to convert it to pixels
|
||||||
if ( !/^-?\d+(?:px)?$/i.test( val ) && /^-?\d/.test( val ) ) {
|
|
||||||
|
if ( !/^-?[0-9]+\.?[0-9]*(?:px)?$/i.test( val ) && /^-?\d/.test( val ) ) {
|
||||||
|
|
||||||
// Remember the original values
|
// Remember the original values
|
||||||
left = style.left;
|
left = style.left;
|
||||||
@ -94,7 +95,13 @@ _html2canvas.Util.getCSS = function (el, attribute) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!/^(thin|medium|thick)$/i.test( val )) {
|
||||||
|
return Math.round(parseFloat( val )) + "px";
|
||||||
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,8 +121,7 @@ _html2canvas.Util.getCSS = function (el, attribute) {
|
|||||||
// IE 9>
|
// IE 9>
|
||||||
if (attribute === "backgroundPosition") {
|
if (attribute === "backgroundPosition") {
|
||||||
// Older IE uses -x and -y
|
// Older IE uses -x and -y
|
||||||
val = [ toPX( attribute + "X", el.currentStyle[ attribute + "X" ] ), toPX( attribute + "Y", el.currentStyle[ attribute + "X" ] ) ];
|
val = [ toPX( attribute + "X", el.currentStyle[ attribute + "X" ] ), toPX( attribute + "Y", el.currentStyle[ attribute + "Y" ] ) ];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
val = toPX( attribute, el.currentStyle[ attribute ] );
|
val = toPX( attribute, el.currentStyle[ attribute ] );
|
||||||
@ -212,8 +218,9 @@ _html2canvas.Util.Children = function(el) {
|
|||||||
// $(el).contents() !== el.childNodes, Opera / IE have issues with that
|
// $(el).contents() !== el.childNodes, Opera / IE have issues with that
|
||||||
var children;
|
var children;
|
||||||
try {
|
try {
|
||||||
children = $(el).contents();
|
// children = $(el).contents();
|
||||||
// children = (el.nodeName && el.nodeName.toUpperCase() === "IFRAME") ? el.contentDocument || el.contentWindow.document : Array.prototype.push.call([], el.childNodes );
|
children = (el.nodeName && el.nodeName.toUpperCase() === "IFRAME") ? el.contentDocument || el.contentWindow.document : el.childNodes ;
|
||||||
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
h2clog("html2canvas.Util.Children failed with exception: " + ex.message);
|
h2clog("html2canvas.Util.Children failed with exception: " + ex.message);
|
||||||
children = [];
|
children = [];
|
||||||
|
@ -144,7 +144,8 @@ _html2canvas.Preload = function( options ) {
|
|||||||
|
|
||||||
// TODO add multi image background support
|
// TODO add multi image background support
|
||||||
|
|
||||||
if (background_image.substring(0,7) === "-webkit" || background_image.substring(0,3) === "-o-" || background_image.substring(0,4) === "-moz") {
|
if (/^(-webkit|-o|-moz|-ms|linear)-/.test( background_image )) {
|
||||||
|
// if (background_image.substring(0,7) === "-webkit" || background_image.substring(0,3) === "-o-" || background_image.substring(0,4) === "-moz") {
|
||||||
|
|
||||||
img = _html2canvas.Generate.Gradient( background_image, _html2canvas.Util.Bounds( el ) );
|
img = _html2canvas.Generate.Gradient( background_image, _html2canvas.Util.Bounds( el ) );
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<script src="unit/css.js"></script>
|
<script src="unit/css.js"></script>
|
||||||
<script src="unit/generate.js"></script>
|
<script src="unit/generate.js"></script>
|
||||||
|
<!-- <script src="unit/utils.js"></script> -->
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#borders div {
|
#borders div {
|
||||||
@ -45,10 +45,11 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="qunit"></div>
|
<div id="qunit"></div>
|
||||||
<div id="qunit-fixture" style="visibility:none; height:1px; overflow:scroll;">
|
<div id="qunit-fixture" style="visibility:none; height:1px; overflow:scroll;">
|
||||||
<div id="borders">
|
All the tests here. <b>Testing different <span>stuff</span> for contents()</b>
|
||||||
<div style="border-width: 1px 0;"></div>
|
<div id="borders">Yep, here's some more.
|
||||||
<div style="border-width: 1em 0;"></div>
|
<div style="border-width: 1px 0;">Div 1</div>
|
||||||
<div style="border-width: thin medium thick;"></div>
|
<div style="border-width: 1em 0;">Div 2</div>
|
||||||
|
<div style="border-width: thin medium thick;">Some more divs</div>
|
||||||
<div style="border-width: 5% 6px 12%;"></div> <!-- percentages aren't valid -->
|
<div style="border-width: 5% 6px 12%;"></div> <!-- percentages aren't valid -->
|
||||||
<div style="border-width: 5em 5ex 5in 5cm;"></div>
|
<div style="border-width: 5em 5ex 5in 5cm;"></div>
|
||||||
<div style="border-width: 500em 500ex 500in 500cm;"></div>
|
<div style="border-width: 500em 500ex 500in 500cm;"></div>
|
||||||
@ -126,8 +127,25 @@
|
|||||||
<div class="linearGradientWithStops"></div>
|
<div class="linearGradientWithStops"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--
|
||||||
|
<div id="fixture-iframes"></div>
|
||||||
|
|
||||||
<!-- <iframe src="../borders.html" id="borders"></iframe> -->
|
<script>
|
||||||
|
var pages = ["background","borders","external-content","forms","images","lists","origin","overflow","proxy","text-linethrough"],
|
||||||
|
fixtures = $("#fixture-iframes");
|
||||||
|
|
||||||
|
|
||||||
|
$.each(pages, function(i, page){
|
||||||
|
|
||||||
|
var iframe = $('<iframe />').attr('src',"../" + page + ".html");
|
||||||
|
|
||||||
|
iframe.insertAfter( fixtures );
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<iframe src="../borders.html" id="borders"></iframe> -->
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// declare vars (preventing JSHint messages)
|
// declare vars (preventing JSHint messages)
|
||||||
|
/* this breaks the testing for IE<9, haven't really looked into why
|
||||||
var test = test || function(){},
|
var test = test || function(){},
|
||||||
QUnit = QUnit || {},
|
QUnit = QUnit || {},
|
||||||
_html2canvas = _html2canvas || {};
|
_html2canvas = _html2canvas || {};
|
||||||
|
*/
|
||||||
|
|
||||||
module("CSS");
|
module("CSS");
|
||||||
$(function() {
|
$(function() {
|
||||||
@ -144,6 +145,6 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO add backgroundPosition % tests
|
// TODO add backgroundPosition % tests
|
||||||
|
|
||||||
});
|
});
|
18
tests/qunit/unit/utils.js
Normal file
18
tests/qunit/unit/utils.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
|
||||||
|
var el = $('#qunit-fixture');
|
||||||
|
|
||||||
|
|
||||||
|
test('Children()', 1, function() {
|
||||||
|
var arr = [],
|
||||||
|
cont = el.contents();
|
||||||
|
$.each(cont, function(i,e){
|
||||||
|
arr.push(e);
|
||||||
|
});
|
||||||
|
// text nodes differ
|
||||||
|
QUnit.equal( _html2canvas.Util.Children(el[0]), arr, "Util.Children === jQuery.children()" );
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user