2008-04-28 23:56:07 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
2013-08-21 16:11:26 +00:00
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=379959
|
2008-04-28 23:56:07 +00:00
|
|
|
-->
|
|
|
|
<head>
|
2013-08-21 16:11:26 +00:00
|
|
|
<title>Test for Bug 379959</title>
|
2008-04-28 23:56:07 +00: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 16:11:26 +00:00
|
|
|
<body onload="runTest();">
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=379959">Mozilla Bug 379959</a>
|
2008-04-28 23:56:07 +00: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>
|
|
|
|
<iframe id="f"></iframe>
|
|
|
|
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="application/javascript;version=1.7">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var messages = 0;
|
|
|
|
|
2013-08-21 16:11:26 +00:00
|
|
|
function receiveMessage(e) {
|
2010-03-12 21:53:36 +00:00
|
|
|
is(e.origin, "http://mochi.test:8888", "wrong sender!");
|
2008-05-02 21:39:06 +00:00
|
|
|
messages++;
|
2013-08-21 16:11:26 +00:00
|
|
|
|
|
|
|
switch (messages) {
|
|
|
|
case 1:
|
|
|
|
receiveMessage1(e.data);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
receiveMessage2(e.data);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
receiveMessage3(e.data);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
receiveMessage4(e.data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(false, "should not be reached");
|
|
|
|
Simpletest.finish();
|
|
|
|
}
|
2008-05-02 21:39:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("message", receiveMessage, false);
|
2008-04-28 23:56:07 +00:00
|
|
|
|
2013-08-21 16:11:26 +00:00
|
|
|
var iframe = document.getElementById('f');
|
2008-04-28 23:56:07 +00:00
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
// Test with data-urls off
|
2013-08-21 16:11:26 +00:00
|
|
|
SpecialPowers.pushPrefEnv({"set": [["layout.debug.enable_data_xbl", false]]}, runTest1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest1() {
|
2008-04-28 23:56:07 +00:00
|
|
|
iframe.src = "file_bug379959_data.html";
|
2013-08-21 16:11:26 +00:00
|
|
|
}
|
2008-04-28 23:56:07 +00:00
|
|
|
|
2013-08-21 16:11:26 +00:00
|
|
|
function receiveMessage1(aData) {
|
|
|
|
is(aData, 0, "data-url load should have failed");
|
2008-04-28 23:56:07 +00:00
|
|
|
// Test with data-urls on
|
2013-08-21 16:11:26 +00:00
|
|
|
SpecialPowers.pushPrefEnv({"set": [["layout.debug.enable_data_xbl", true]]}, runTest2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest2() {
|
2008-04-28 23:56:07 +00:00
|
|
|
iframe.src = "file_bug379959_data.html";
|
2013-08-21 16:11:26 +00:00
|
|
|
}
|
2008-04-28 23:56:07 +00:00
|
|
|
|
2013-08-21 16:11:26 +00:00
|
|
|
function receiveMessage2(aData) {
|
|
|
|
is(aData, 1, "data-url load should have been successful");
|
2008-04-28 23:56:07 +00:00
|
|
|
// Try a cross-site load
|
|
|
|
iframe.src = "file_bug379959_cross.html";
|
2013-08-21 16:11:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function receiveMessage3(aData) {
|
|
|
|
is(aData, 1, "same site load should have succeeded");
|
|
|
|
}
|
|
|
|
|
|
|
|
function receiveMessage4(aData) {
|
|
|
|
is(aData, 0, "cross site load should have failed");
|
2008-04-28 23:56:07 +00:00
|
|
|
|
|
|
|
// Check that we got the right number of messages to make sure that
|
|
|
|
// the right message has aligned with the right test
|
|
|
|
is(messages, 4, "wrong number of messages");
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
2013-08-21 16:11:26 +00:00
|
|
|
|
2008-04-28 23:56:07 +00:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|