2008-04-29 03:56:07 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
2013-08-21 20:11:26 +04:00
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=379959
|
2008-04-29 03:56:07 +04:00
|
|
|
-->
|
|
|
|
<head>
|
2013-08-21 20:11:26 +04:00
|
|
|
<title>Test for Bug 379959</title>
|
2008-04-29 03:56:07 +04:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
2013-08-21 20:11:26 +04:00
|
|
|
<body onload="runTest();">
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=379959">Mozilla Bug 379959</a>
|
2008-04-29 03:56:07 +04:00
|
|
|
<p id="display">
|
|
|
|
Note: In order to re-run this test correctly you need to shift-reload
|
|
|
|
rather than simply reload. If you just reload we will restore the
|
|
|
|
previous url in the iframe which will result in an extra unexpected
|
|
|
|
message.
|
|
|
|
</p>
|
|
|
|
<div id="content" style="display: none"></div>
|
2015-08-20 22:28:51 +03:00
|
|
|
<iframe id="dataFrame"></iframe>
|
|
|
|
<iframe id="originFrame"></iframe>
|
2008-04-29 03:56:07 +04:00
|
|
|
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="application/javascript;version=1.7">
|
2015-08-20 22:28:51 +03:00
|
|
|
|
2008-04-29 03:56:07 +04:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2015-08-20 22:28:51 +03:00
|
|
|
var seenData = false;
|
|
|
|
var seenSameOrigin = false;
|
|
|
|
var seenCrossOrign = false;
|
2008-04-29 03:56:07 +04:00
|
|
|
|
2013-08-21 20:11:26 +04:00
|
|
|
function receiveMessage(e) {
|
2010-03-13 00:53:36 +03:00
|
|
|
is(e.origin, "http://mochi.test:8888", "wrong sender!");
|
2013-08-21 20:11:26 +04:00
|
|
|
|
2015-08-20 22:28:51 +03:00
|
|
|
if (e.data.test === "dataIsAllowed") {
|
|
|
|
is(e.data.result, 1, "data-url load should have succeeded");
|
|
|
|
seenData = true;
|
|
|
|
}
|
|
|
|
else if (e.data.test === "sameOriginIsAllowed") {
|
|
|
|
is(e.data.result, 1, "same site load should have succeeded");
|
|
|
|
seenSameOrigin = true;
|
|
|
|
}
|
|
|
|
else if (e.data.test === "crossOriginIsBlocked") {
|
|
|
|
is(e.data.result, 0, "cross site load should have failed");
|
|
|
|
seenCrossOrign = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok (false, "unrecognized test");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seenData && seenSameOrigin && seenCrossOrign) {
|
|
|
|
window.removeEventListener("message", receiveMessage, false);
|
|
|
|
SimpleTest.finish();
|
2013-08-21 20:11:26 +04:00
|
|
|
}
|
2008-05-03 01:39:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("message", receiveMessage, false);
|
2008-04-29 03:56:07 +04:00
|
|
|
|
|
|
|
function runTest() {
|
2015-08-20 22:28:51 +03:00
|
|
|
// make sure data: is allowed
|
|
|
|
document.getElementById('dataFrame').src = "file_bug379959_data.html";
|
|
|
|
// make sure same-origin is allowed but cross site is blocked
|
|
|
|
document.getElementById('originFrame').src = "file_bug379959_cross.html";
|
2008-04-29 03:56:07 +04:00
|
|
|
}
|
2013-08-21 20:11:26 +04:00
|
|
|
|
2008-04-29 03:56:07 +04:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|