mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
95 lines
2.5 KiB
HTML
95 lines
2.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=878577
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 878577 - Hard limit of decoded image buffer size</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="imgutils.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!--
|
|
Initial setup: The default size limit is 65M
|
|
Step 1: Load 6M-pixels.png ok
|
|
Step 2: Load 12M-pixels-1.png fail
|
|
Step 3: Remove 6M-pixels.png and clear the decoded image
|
|
Step 4: Load 12M-pixels-2.png ok
|
|
-->
|
|
|
|
<script>
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
function loadImage(url) {
|
|
info('loading ' + url);
|
|
var image = new Image(50,50);
|
|
image.src = url;
|
|
document.body.appendChild(image);
|
|
return image;
|
|
}
|
|
|
|
function fail(msg) {
|
|
return function() {
|
|
ok(false, msg);
|
|
SimpleTest.finish();
|
|
};
|
|
}
|
|
|
|
function runTest() {
|
|
// provide a clean setup
|
|
clearImageCache();
|
|
|
|
var img_6M = loadImage('6M-pixels.png');
|
|
img_6M.onerror = fail('unable to load 6M-pixels.png');
|
|
img_6M.onload = function() {
|
|
ok(true, 'expect success on loading a 6M-pixel image');
|
|
|
|
var img_12M = loadImage('12M-pixels-1.png');
|
|
img_12M.onload = fail('should fail to load due to image buffer size limit');
|
|
img_12M.onerror = function() {
|
|
ok(true, 'expect fail on loading a 12M-pixel image');
|
|
|
|
// remove image cache
|
|
info('discard decoded image buffer');
|
|
img_6M.onerror = null;
|
|
img_6M.src = null;
|
|
img_12M.onerror = null;
|
|
img_12M.src = null;
|
|
document.body.removeChild(img_6M);
|
|
document.body.removeChild(img_12M);
|
|
clearImageCache();
|
|
|
|
// Spin the event to give the image a chance to be discarded.
|
|
SimpleTest.executeSoon(function() {
|
|
var another_img_12M = loadImage('12M-pixels-2.png');
|
|
another_img_12M.onerror = fail('unable to load 12M-pixels-2.png');
|
|
another_img_12M.onload = function() {
|
|
ok(true, 'expect success on loading another 12M-pixel image');
|
|
another_img_12M.onerror = null;
|
|
another_img_12M.onload = null;
|
|
SimpleTest.finish();
|
|
}; // another_img_12M.onload
|
|
});
|
|
|
|
}; // img_12M.onerror
|
|
}; // img_6M.onload
|
|
}
|
|
|
|
window.addEventListener("load", function() {
|
|
SpecialPowers.pushPrefEnv({
|
|
"set": [
|
|
// XXX prevent displayed imgFrame been released
|
|
["image.mem.allow_locking_in_content_processes", true]
|
|
]
|
|
}, runTest);
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|