mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 878577 - Part 2: Add test case for the hard limit of image buffer size. r=seth
This commit is contained in:
parent
0e66b7f2bd
commit
3f7b123b88
BIN
image/test/mochitest/12M-pixels-1.png
Normal file
BIN
image/test/mochitest/12M-pixels-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
image/test/mochitest/12M-pixels-2.png
Normal file
BIN
image/test/mochitest/12M-pixels-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
image/test/mochitest/6M-pixels.png
Normal file
BIN
image/test/mochitest/6M-pixels.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
@ -1,5 +1,4 @@
|
||||
[DEFAULT]
|
||||
skip-if = buildapp == 'b2g'
|
||||
support-files =
|
||||
INT32_MIN.bmp
|
||||
animated-gif2.gif
|
||||
@ -54,10 +53,13 @@ support-files =
|
||||
short_header.gif
|
||||
source.png
|
||||
over.png
|
||||
6M-pixels.png
|
||||
12M-pixels-1.png
|
||||
12M-pixels-2.png
|
||||
|
||||
[test_ImageContentLoaded.html]
|
||||
[test_bug399925.html]
|
||||
skip-if = e10s
|
||||
skip-if = e10s || buildapp == 'b2g' #Bug 969779 - should set preference via SpecialPowers.pushPrefEnv()
|
||||
# [test_bug435296.html]
|
||||
# disabled - See bug 578591
|
||||
[test_bug466586.html]
|
||||
@ -82,5 +84,8 @@ skip-if = e10s
|
||||
[test_bug89419-2.html]
|
||||
[test_animation_operators.html]
|
||||
[test_drawDiscardedImage.html]
|
||||
skip-if = toolkit == "gonk" #Bug 997034 - canvas.toDataURL() often causes lost connection to device.
|
||||
[test_error_events.html]
|
||||
[test_short_gif_header.html]
|
||||
[test_image_buffer_limit.html]
|
||||
run-if = toolkit == "gonk" #Image buffer limit is only set for Firefox OS currently.
|
||||
|
94
image/test/mochitest/test_image_buffer_limit.html
Normal file
94
image/test/mochitest/test_image_buffer_limit.html
Normal file
@ -0,0 +1,94 @@
|
||||
<!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>
|
||||
|
Loading…
Reference in New Issue
Block a user