Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: true
- Manifest: dom/html/test/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<script 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=445004">Mozilla Bug 445004</a>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
is(window.location.hostname, "mochi.test", "Unexpected hostname");
is(window.location.port, "8888", "Unexpected port; fix testcase");
SimpleTest.waitForExplicitFinish();
var loads = 1;
function loadStarted() {
++loads;
}
function loadEnded() {
--loads;
if (loads == 0) {
doTest();
}
}
window.onload = loadEnded;
function getMessage(evt) {
ok(evt.data == "start" || evt.data == "end", "Must have start or end");
if (evt.data == "start")
loadStarted();
else
loadEnded();
}
window.addEventListener("message", getMessage);
function checkURI(uri, name, type) {
var host = uri.match(/^http:\/\/([a-z.0-9]*)/)[1];
var file = uri.match(/([^\/]*).png$/)[1];
is(host, file, "Unexpected base URI for test " + name +
" when testing " + type);
}
function checkFrame(num) {
// Just snarf our data
var outer = SpecialPowers.wrap(window.frames[num]);
name = outer.name;
is(outer.document.baseURI,
"Unexpected base URI for " + name);
var iswrite = name.match(/write/);
var inner = outer.frames[0];
if (iswrite) {
is(inner.document.baseURI,
"Unexpected inner base URI for " + name);
} else {
is(inner.document.baseURI,
"Unexpected inner base URI for " + name);
}
var isrel = name.match(/rel/);
var offsite = name.match(/offsite/);
if (!iswrite) {
if ((isrel && !offsite) || (!isrel && offsite)) {
is(inner.location.hostname, outer.location.hostname,
"Unexpected hostnames for " + name);
} else {
isnot(inner.location.hostname, outer.location.hostname,
"Unexpected hostnames for " + name);
}
}
checkURI(inner.frames[0].location.href, name, "direct location");
checkURI(inner.frames[1].document.getElementsByTagName("img")[0].src,
name, "direct write");
if (!iswrite) {
is(inner.frames[1].location.hostname, inner.location.hostname,
"Incorrect hostname for " + name + " direct write")
}
checkURI(inner.frames[2].location.href, name, "indirect location");
checkURI(inner.frames[3].document.getElementsByTagName("img")[0].src,
name, "indirect write");
if (!iswrite) {
is(inner.frames[3].location.hostname, outer.location.hostname,
"Incorrect hostname for " + name + " indirect write")
}
checkURI(inner.document.getElementsByTagName("img")[0].src,
name, "direct image load");
}
function doTest() {
for (var num = 0; num < 5; ++num) {
checkFrame(num);
}
SimpleTest.finish();
}
</script>
</pre>
<p id="display">
<iframe
<iframe
<iframe
<iframe
<iframe
</p>
</body>
</html>