зеркало из https://github.com/mozilla/gecko-dev.git
Adding test
This commit is contained in:
Родитель
bf4ac68359
Коммит
ed9afe6723
|
@ -482,6 +482,7 @@ _TEST_FILES_E = \
|
|||
test_2d.imageData.put.unchanged.html \
|
||||
test_2d.imageData.put.unaffected.html \
|
||||
test_2d.imageData.put.path.html \
|
||||
test_bug397524.html \
|
||||
test_bug405982.html \
|
||||
image_transparent50.png \
|
||||
image_redtransparent.png \
|
||||
|
@ -489,6 +490,8 @@ _TEST_FILES_E = \
|
|||
image_green-16x16.png \
|
||||
image_red-16x16.png \
|
||||
image_green-1x1.png \
|
||||
image_green-redirect \
|
||||
image_green-redirect^headers^ \
|
||||
image_ggrr-256x256.png \
|
||||
image_yellow75.png \
|
||||
image_broken.png \
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
HTTP 302 Moved
|
||||
Location: http://example.com/tests/content/canvas/test/image_green-1x1.png
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=397524
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 397524</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/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=397524">Mozilla Bug 397524</a>
|
||||
<p id="display">
|
||||
<canvas id="c1" width="1" height="1"></canvas>
|
||||
<canvas id="c2" width="1" height="1"></canvas>
|
||||
<canvas id="c3" width="1" height="1"></canvas>
|
||||
<img id="i1", src="image_green-1x1.png">
|
||||
<img id="i2" src="http://example.com/tests/content/canvas/test/image_green-1x1.png">
|
||||
<img id="i3" src="image_green-redirect">
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 397524 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function draw(n) {
|
||||
$("c" + n).getContext('2d').drawImage($("i" + n), 0, 0);
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
draw(1);
|
||||
draw(2);
|
||||
draw(3);
|
||||
|
||||
// Should be able to get the data out of the first canvas
|
||||
$("c1").toDataURL("image/png");
|
||||
|
||||
// Should not be able to get the data out of a cross-site load
|
||||
var gotData = false;
|
||||
try {
|
||||
$("c2").toDataURL("image/png");
|
||||
gotData = true;
|
||||
} catch (ex if (ex.code == 1000 && ex.name == "NS_ERROR_DOM_SECURITY_ERR")) {
|
||||
}
|
||||
is(gotData, false, "Shouldn't be able to read images cross-site!");
|
||||
|
||||
// Should not be able to get the data out of a redirected cross-site load
|
||||
var gotData = false;
|
||||
try {
|
||||
$("c3").toDataURL("image/png");
|
||||
gotData = true;
|
||||
} catch (ex if (ex.code == 1000 && ex.name == "NS_ERROR_DOM_SECURITY_ERR")) {
|
||||
}
|
||||
is(gotData, false, "Shouldn't be able to read images redirected cross-site!");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Загрузка…
Ссылка в новой задаче