зеркало из https://github.com/mozilla/pjs.git
Bug 497665 and Bug 514605 - Tests.
This commit is contained in:
Родитель
0df5dc508b
Коммит
beb04f57e4
|
@ -66,6 +66,9 @@ _TEST_FILES = imgutils.js \
|
|||
test_bug512435.html \
|
||||
damon.jpg \
|
||||
shaver.png \
|
||||
test_bug497665.html \
|
||||
bug497665-iframe.html \
|
||||
bug497665.sjs \
|
||||
$(NULL)
|
||||
|
||||
#test_bug435296.html disabled until we re-enable decode-on-draw
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bug 497665 iframe</title>
|
||||
<body>
|
||||
<img src="bug497665.sjs" width="100" height="100" id="image1" />
|
||||
<img src="bug497665.sjs" width="100" height="100" id="image2" />
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
function handleRequest(request, response)
|
||||
{
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties)
|
||||
.get("CurWorkD", Components.interfaces.nsIFile);
|
||||
|
||||
file.append("tests");
|
||||
file.append("modules");
|
||||
file.append("libpr0n");
|
||||
file.append("test");
|
||||
file.append("mochitest");
|
||||
|
||||
var redirectstate = "/modules/libpr0n/test/mochitest/bug497665.sjs";
|
||||
if (getState(redirectstate) == "") {
|
||||
file.append('blue.png');
|
||||
setState(redirectstate, "red");
|
||||
} else {
|
||||
file.append('red.png');
|
||||
setState(redirectstate, "");
|
||||
}
|
||||
|
||||
response.setHeader("Cache-Control", "max-age=3600", false);
|
||||
|
||||
var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
|
||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||
fileStream.init(file, 1, 0, false);
|
||||
var binaryStream = Components.classes['@mozilla.org/binaryinputstream;1']
|
||||
.createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||
binaryStream.setInputStream(fileStream);
|
||||
|
||||
response.bodyOutputStream.writeFrom(binaryStream, binaryStream.available());
|
||||
|
||||
binaryStream.close();
|
||||
fileStream.close();
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=497665
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 497665</title>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<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=497665">Mozilla Bug 497665</a>
|
||||
<p id="display"></p>
|
||||
<div id="content"> <!-- style="display: none" -->
|
||||
<canvas id="canvas" width="100" height="100"> </canvas>
|
||||
<iframe id="test-iframe" src="bug497665-iframe.html" onload="checkFirst()"></iframe>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
var image1first, image2first, image1second, image2second, image1third, image2third;
|
||||
var iframeelem = document.getElementById('test-iframe');
|
||||
var canvas = document.getElementById('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function checkFirst()
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
|
||||
var firstimg = iframeelem.contentDocument.getElementById('image1');
|
||||
var secondimg = iframeelem.contentDocument.getElementById('image2');
|
||||
ctx.drawImage(firstimg, 0, 0);
|
||||
image1first = canvas.toDataURL();
|
||||
ctx.drawImage(secondimg, 0, 0);
|
||||
image2first = canvas.toDataURL();
|
||||
|
||||
ok(image1first == image2first, "We got different images, but shouldn't have.");
|
||||
|
||||
iframeelem.onload = checkForceReload;
|
||||
iframeelem.contentWindow.location.reload(true);
|
||||
}
|
||||
|
||||
function checkForceReload()
|
||||
{
|
||||
var firstimg = iframeelem.contentDocument.getElementById('image1');
|
||||
var secondimg = iframeelem.contentDocument.getElementById('image2');
|
||||
ctx.drawImage(firstimg, 0, 0);
|
||||
image1second = canvas.toDataURL();
|
||||
ctx.drawImage(secondimg, 0, 0);
|
||||
image2second = canvas.toDataURL();
|
||||
|
||||
ok(image1second == image2second, "We got different images after a force-reload, but shouldn't have.");
|
||||
|
||||
// Sanity check that we actually reloaded.
|
||||
ok(image1first != image1second, "We got the same images after a force-reload.");
|
||||
|
||||
iframeelem.onload = checkReload;
|
||||
iframeelem.contentWindow.location.reload(false);
|
||||
}
|
||||
|
||||
function checkReload()
|
||||
{
|
||||
var firstimg = iframeelem.contentDocument.getElementById('image1');
|
||||
var secondimg = iframeelem.contentDocument.getElementById('image2');
|
||||
ctx.drawImage(firstimg, 0, 0);
|
||||
image1third = canvas.toDataURL();
|
||||
ctx.drawImage(secondimg, 0, 0);
|
||||
image2third = canvas.toDataURL();
|
||||
|
||||
ok(image1third == image2third, "We got different images after a reload, but shouldn't have.");
|
||||
|
||||
// Sanity check that we actually reloaded properly.
|
||||
ok(image1second != image1third, "We got the same images after a reload.");
|
||||
ok(image1first == image1third, "We didn't loop back to the first image.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче