Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1494)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html

Issue 1901153002: Implement createImageBitmap(SVG) of intrinsic size = 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: null check Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
index b6f756b0ff2226c2bc06193d36238e74e1192ed8..3195433396a6f318258f1513b5f8449f377f77f2 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size.html
@@ -6,20 +6,72 @@
<body>
<script>
-description("Test createImageBitmap from a SVG image without intrinsic size.");
+description("Test createImageBitmap from a SVG image without intrinsic size and with zero size.");
window.jsTestIsAsync = true;
-var image = new Image();
-image.onload = function() {
- createImageBitmap(image).then(function(imageBitmap) {
- testFailed("createImageBitmap promise resolved, expected to be rejected");
- finishJSTest();
- }, function (e) {
- testPassed("createImageBitmap promise rejected: " + e);
- finishJSTest();
- });
+var image1Loaded = false;
+var image2Loaded = false;
+var image1 = new Image();
+var image2 = new Image();
+image1.onload = function() {
+ image1Loaded = true;
+ testCreateImageBitmap();
+}
+image1.src = '../../svg/hixie/intrinsic/resources/003.svg';
+image2.onload = function() {
+ image2Loaded = true;
+ testCreateImageBitmap();
+}
+image2.src = 'resources/zeroSize.svg';
+
+function testCreateImageBitmap()
+{
+ if (image1Loaded && image2Loaded) {
+ createImageBitmap(image1).then(function(bitmap1) {
+ testFailed("createImageBitmap from a SVG without intrinsic size succeed, expected to be rejected");
+ finishJSTest();
+ }, function (e) {
+ testPassed("createImageBitmap from a SVG without intrinsic size rejected: " + e);
+ createImageBitmap(image2).then(function(bitmap2) {
+ testFailed("createImageBitmap from a SVG with zero size succeed, expected to be rejected");
+ finishJSTest();
+ }, function(e) {
+ testPassed("createImageBitmap from a SVG with zero size rejected: " + e);
+ createImageBitmap(image2, 0, 0, 100, 100).then(function(bitmap3) {
+ testPassed("createImageBitmap from a zero size SVG with cropRect succeed");
+ checkImageBitmap(bitmap3);
+ finishJSTest();
+ }, function(e) {
+ testFailed("createImageBitmap from a zero size SVG with cropRect rejected: " + e);
+ finishJSTest();
+ });
+ });
+ });
+ }
+}
+
+function shouldBeClear(ctx, x, y) {
+ // should be transparent black pixels
+ d = ctx.getImageData(x, y, 1, 1).data;
+ shouldBe("d[0]", "0");
+ shouldBe("d[1]", "0");
+ shouldBe("d[2]", "0");
+ shouldBe("d[3]", "0");
+}
+
+function checkImageBitmap(bitmap)
+{
+ var canvas = document.createElement("canvas");
+ canvas.width = 100;
+ canvas.height = 100;
+ var ctx = canvas.getContext('2d');
+ ctx.clearRect(0, 0, 100, 100);
+ ctx.drawImage(bitmap, 0, 0);
+ shouldBeClear(ctx, 0, 0);
+ shouldBeClear(ctx, 0, 99);
+ shouldBeClear(ctx, 99, 0);
+ shouldBeClear(ctx, 99, 99);
}
-image.src = '../../svg/hixie/intrinsic/resources/003.svg';
</script>
</body>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-svg-no-intrinsic-size-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698