Bug 1325080 - Synchronously decode image metadata for data URIs. r=tnikkel

MozReview-Commit-ID: IPrP3EepQ6a
This commit is contained in:
Kevin Hsieh 2017-08-16 19:04:20 -07:00
Родитель 90080d65c7
Коммит 2ab70861b6
3 изменённых файлов: 46 добавлений и 0 удалений

Просмотреть файл

@ -75,6 +75,14 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
imageFlags |= Image::INIT_FLAG_TRANSIENT;
}
// Synchronously decode metadata (including size) if we have a data URI since
// the data is immediately available.
bool isDataURI = false;
rv = uri->SchemeIs("data", &isDataURI);
if (NS_SUCCEEDED(rv) && isDataURI) {
imageFlags |= Image::INIT_FLAG_SYNC_LOAD;
}
return imageFlags;
}

Просмотреть файл

@ -125,6 +125,7 @@ skip-if = true # disabled - See bug 579139
skip-if = os == 'android'
[test_bug1180105.html]
[test_bug1217571.html]
[test_bug1325080.html]
[test_bullet_animation.html]
skip-if = os == 'android'
[test_changeOfSource.html]

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1325080
-->
<head>
<title>Test for Bug 1325080</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1325080">Mozilla Bug 1325080</a>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 1325080 **/
SimpleTest.waitForExplicitFinish();
function createImage() {
// This function's code comes from the Acid3 test #72
document.open();
document.write('<!DOCTYPE html><head><style>img { height: 10px; }</style></head><body><img src="data:image/gif;base64,R0lGODlhAQABAID%2FAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" alt="alt-text"></body>');
document.close();
}
window.onload = function() {
createImage();
SimpleTest.executeSoon(() => {
ok(document.images[0].height == 10, "Style should set height of image.");
SimpleTest.finish();
});
}
</script>
</pre>
</body>
</html>