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

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-toDataURL-case-insensitive-mimetype.js

Issue 1302423004: Support lossy and lossless <canvas>.toDataURL for webp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing. Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 description("Test that toDataURL(mimeType) ignores the case of 'mimeType'."); 1 description("Test that toDataURL(mimeType) ignores the case of 'mimeType'.");
2 2
3 canvas = document.createElement('canvas'); 3 canvas = document.createElement('canvas');
4 4
5 function tryMimeType(mimeType) { 5 function tryMimeType(mimeType) {
6 re = new RegExp("^data:([^;,]+)[;,].*"); 6 re = new RegExp("^data:([^;,]+)[;,].*");
7 data = canvas.toDataURL(mimeType); 7 data = canvas.toDataURL(mimeType);
8 caps = data.match(re); 8 caps = data.match(re);
9 if (caps.length != 2) 9 if (caps.length != 2)
10 return "FAIL"; 10 return "FAIL";
11 return caps[1]; 11 return caps[1];
12 } 12 }
13 13
14 shouldBe("tryMimeType('image/png')", "'image/png'"); 14 shouldBe("tryMimeType('image/png')", "'image/png'");
15 shouldBe("tryMimeType('iMAge/Png')", "'image/png'"); 15 shouldBe("tryMimeType('iMAge/Png')", "'image/png'");
16 shouldBe("tryMimeType('IMAGE/PNG')", "'image/png'"); 16 shouldBe("tryMimeType('IMAGE/PNG')", "'image/png'");
17 17
18 if (tryMimeType("image/jpeg") == "image/jpeg") { 18 if (tryMimeType("image/jpeg") == "image/jpeg") {
19 shouldBe("tryMimeType('image/jpeg')", "'image/jpeg'"); 19 shouldBe("tryMimeType('image/jpeg')", "'image/jpeg'");
20 shouldBe("tryMimeType('imAgE/jPEg')", "'image/jpeg'"); 20 shouldBe("tryMimeType('imAgE/jPEg')", "'image/jpeg'");
21 shouldBe("tryMimeType('IMAGE/JPEG')", "'image/jpeg'"); 21 shouldBe("tryMimeType('IMAGE/JPEG')", "'image/jpeg'");
22 } 22 }
23
24 if (tryMimeType("image/webp") == "image/webp") {
25 shouldBe("tryMimeType('image/webp')", "'image/webp'");
26 shouldBe("tryMimeType('imAgE/wEBp')", "'image/webp'");
27 shouldBe("tryMimeType('IMAGE/WEBP')", "'image/webp'");
28
29 shouldBe("tryMimeType('image/webp.ll')", "'image/webp'");
30 shouldBe("tryMimeType('imAgE/wEBp.Ll')", "'image/webp'");
31 shouldBe("tryMimeType('IMAGE/WEBP.LL')", "'image/webp'");
32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698