mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 03:18:41 +00:00
Bug 630511 - Lowercase mime type argument to toDataURL; r=sicking
This commit is contained in:
parent
9f951e30b0
commit
152132c477
@ -15,7 +15,7 @@
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Corporation.
|
||||
# the Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
@ -79,6 +79,7 @@ _TEST_FILES_0 = \
|
||||
test_2d.composite.uncovered.image.destination-in.html \
|
||||
test_2d.composite.uncovered.image.source-in.html \
|
||||
test_2d.composite.uncovered.image.source-out.html \
|
||||
test_toDataURL_lowercase_ascii.html \
|
||||
test_mozGetAsFile.html \
|
||||
test_canvas_strokeStyle_getter.html \
|
||||
test_bug613794.html \
|
||||
|
21
content/canvas/test/test_toDataURL_lowercase_ascii.html
Normal file
21
content/canvas/test/test_toDataURL_lowercase_ascii.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML>
|
||||
<title>Canvas test: toDataURL.lowercase.ascii</title>
|
||||
<script src="/MochiKit/MochiKit.js"></script>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
||||
<body>
|
||||
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<script>
|
||||
var canvas = document.getElementById('c');
|
||||
var ctx = canvas.getContext("2d");
|
||||
|
||||
var data = canvas.toDataURL('ImAgE/PnG');
|
||||
ok(data.match(/^data:image\/png[;,]/), "data =~ /^data:image\\/png[;,]/");
|
||||
|
||||
// If JPEG is supported at all, it must be supported case-insensitively
|
||||
data = canvas.toDataURL('image/jpeg');
|
||||
if (data.match(/^data:image\/jpeg[;,]/)) {
|
||||
data = canvas.toDataURL('ImAgE/JpEg');
|
||||
ok(data.match(/^data:image\/jpeg[;,]/), "data =~ /^data:image\\/jpeg[;,]/");
|
||||
}
|
||||
</script>
|
@ -247,8 +247,7 @@ nsHTMLCanvasElement::ExtractData(const nsAString& aType,
|
||||
|
||||
// get image bytes
|
||||
nsCOMPtr<nsIInputStream> imgStream;
|
||||
nsCAutoString encoderType;
|
||||
encoderType.Assign(NS_ConvertUTF16toUTF8(aType));
|
||||
NS_ConvertUTF16toUTF8 encoderType(aType);
|
||||
|
||||
try_again:
|
||||
if (mCurrentContext) {
|
||||
@ -334,10 +333,13 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
|
||||
{
|
||||
bool fallbackToPNG = false;
|
||||
|
||||
nsAutoString type;
|
||||
nsContentUtils::ASCIIToLower(aMimeType, type);
|
||||
|
||||
PRUint32 imgSize = 0;
|
||||
char* imgData;
|
||||
|
||||
nsresult rv = ExtractData(aMimeType, aEncoderOptions, imgData,
|
||||
nsresult rv = ExtractData(type, aEncoderOptions, imgData,
|
||||
imgSize, fallbackToPNG);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -352,7 +354,7 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
|
||||
aDataURL = NS_LITERAL_STRING("data:image/png;base64,") +
|
||||
NS_ConvertUTF8toUTF16(encodedImg);
|
||||
else
|
||||
aDataURL = NS_LITERAL_STRING("data:") + aMimeType +
|
||||
aDataURL = NS_LITERAL_STRING("data:") + type +
|
||||
NS_LITERAL_STRING(";base64,") + NS_ConvertUTF8toUTF16(encodedImg);
|
||||
|
||||
PR_Free(encodedImg);
|
||||
|
Loading…
Reference in New Issue
Block a user