зеркало из https://github.com/mozilla/gecko-dev.git
Bug 671906 - Test to make sure we always reload images validated using CORS if their principal has changed. r=bz
This commit is contained in:
Родитель
39edc16be7
Коммит
35f7e4c995
|
@ -83,6 +83,9 @@ _TEST_FILES = imgutils.js \
|
|||
test_bug552605-1.html \
|
||||
test_bug552605-2.html \
|
||||
bug552605.sjs \
|
||||
bug671906-iframe.html \
|
||||
bug671906.sjs \
|
||||
test_bug671906.html \
|
||||
$(NULL)
|
||||
|
||||
# Tests disabled due to intermittent orange
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bug 671906 iframe</title>
|
||||
<body>
|
||||
<img src="http://mochi.test:8888/tests/modules/libpr0n/test/mochitest/bug671906.sjs" width="100" height="100" crossorigin="anonymous" />
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
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 filestate = "/modules/libpr0n/test/mochitest/bug671906.sjs";
|
||||
if (getState(filestate) == "") {
|
||||
file.append('blue.png');
|
||||
setState(filestate, "red");
|
||||
} else {
|
||||
file.append('red.png');
|
||||
setState(filestate, "");
|
||||
}
|
||||
|
||||
// Set the expires date to some silly time in the future so we're sure to
|
||||
// *want* to cache this image.
|
||||
var date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
response.setHeader("Expires", date.toUTCString(), false);
|
||||
|
||||
var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
|
||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||
fileStream.init(file, 1, 0, false);
|
||||
|
||||
response.bodyOutputStream.writeFrom(fileStream, fileStream.available());
|
||||
|
||||
fileStream.close();
|
||||
|
||||
response.setHeader("Access-Control-Allow-Origin", "*", false);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=671906
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 671906</title>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.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=671906">Mozilla Bug 671906</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
var first, second, third;
|
||||
var correct, val1, val2;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function snapshotFirst()
|
||||
{
|
||||
var iframeelem = document.getElementById('test-iframe');
|
||||
first = snapshotWindow(iframeelem.contentWindow, false);
|
||||
|
||||
iframeelem.onload = snapshotSecond;
|
||||
iframeelem.src = "http://example.com/tests/modules/libpr0n/test/mochitest/bug671906-iframe.html";
|
||||
}
|
||||
|
||||
function snapshotSecond()
|
||||
{
|
||||
var iframeelem = document.getElementById('test-iframe');
|
||||
second = snapshotWindow(iframeelem.contentWindow, false);
|
||||
|
||||
// We must have loaded the image again, because the principals for the
|
||||
// loading document are different.
|
||||
[correct, val1, val2] = compareSnapshots(first, second, false);
|
||||
ok(correct, "Image should have changed after changing the iframe's src.");
|
||||
|
||||
iframeelem.onload = snapshotThird;
|
||||
iframeelem.src = "http://mochi.test:8888/tests/modules/libpr0n/test/mochitest/bug671906-iframe.html";
|
||||
}
|
||||
|
||||
function snapshotThird()
|
||||
{
|
||||
var iframeelem = document.getElementById('test-iframe');
|
||||
third = snapshotWindow(iframeelem.contentWindow, false);
|
||||
|
||||
// We must have loaded the image again, because the principals for the
|
||||
// loading document are different.
|
||||
[correct, val1, val2] = compareSnapshots(second, third, false);
|
||||
ok(correct, "Image should have changed after changing the iframe's src.");
|
||||
|
||||
// We must have looped back to the first image, because the sjs only sends
|
||||
// one of two images.
|
||||
[correct, val1, val2] = compareSnapshots(first, third, true);
|
||||
ok(correct, "Image should be the same on the third load.");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<div id="content"> <!-- style="display: none" -->
|
||||
<iframe id="test-iframe" src="http://mochi.test:8888/tests/modules/libpr0n/test/mochitest/bug671906-iframe.html" onload="snapshotFirst()"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче