OLD | NEW |
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 } |
OLD | NEW |