Index: LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html |
diff --git a/LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html b/LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..83fd7430c8bcecb0e7746d6383cfe6d478547095 |
--- /dev/null |
+++ b/LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html |
@@ -0,0 +1,38 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<pre id="result"></pre> |
+<canvas id="canvas" width="100" height="50"></canvas> |
+<script> |
+if (window.testRunner) |
+ testRunner.dumpAsText(); |
+ |
+var canvas = document.getElementById('canvas'); |
+var ctx = canvas.getContext("2d"); |
+for (var i = 0; i < 30; i += 5) { |
+ ctx.fillStyle = 'rgba(1, 3, 254, 1)'; |
+ ctx.fillRect( 0 + i, i, 25, 25); |
+ ctx.fillStyle = 'rgba(8, 252, 248, 0.75)'; |
+ ctx.fillRect(25 + i, i, 25, 25); |
+ ctx.fillStyle = 'rgba(6, 10, 250, 0.502)'; |
+ ctx.fillRect(50 - i, i, 25, 25); |
+ ctx.fillRect(50 + i, i, 25, 25); |
+ ctx.fillStyle = 'rgba(12, 16, 244, 0.25)'; |
+ ctx.fillRect(75 - i, i, 25, 25); |
+ ctx.fillRect(75 + i, i, 25, 25); |
+} |
+ |
+function dataURLLength(compression) { |
+ var length = canvas.toDataURL("image/png", compression).length; |
+ result.textContent += compression.toFixed(1) + ' '; |
+ result.textContent += 'toDataURL image/png length ' + length + '\n'; |
+ return length; |
+} |
+ |
+var length3 = dataURLLength(0.3); |
+var length9 = dataURLLength(0.9); |
+ |
+result.textContent += (length9 < length3 * 0.7) ? "\nPASS" : "\nFAIL"; |
+</script> |
+</body> |
+<html> |