123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <!DOCTYPE HTML>
- <html>
- <!--
- https://bugzilla.mozilla.org/show_bug.cgi?id=445004
- -->
- <head>
- <title>Test for Bug 445004</title>
- <script type="application/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=445004">Mozilla Bug 445004</a>
- <div id="content" style="display: none">
-
- </div>
- <pre id="test">
- <script type="application/javascript">
- /** Test for Bug 445004 **/
- 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, false);
- 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,
- "http://example.org/tests/dom/html/test/bug445004-outer.html",
- "Unexpected base URI for " + name);
- var iswrite = name.match(/write/);
- var inner = outer.frames[0];
- if (iswrite) {
- is(inner.document.baseURI,
- "http://example.org/tests/dom/html/test/bug445004-outer.html",
- "Unexpected inner base URI for " + name);
- } else {
- is(inner.document.baseURI,
- "http://test1.example.org/tests/dom/html/test/bug445004-inner.html",
- "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
- src="http://example.org/tests/dom/html/test/bug445004-outer-rel.html"
- name="bug445004-outer-rel.html"></iframe>
- <iframe
- src="http://test1.example.org/tests/dom/html/test/bug445004-outer-rel.html"
- name="bug445004-outer-rel.html offsite"></iframe>
- <iframe
- src="http://example.org/tests/dom/html/test/bug445004-outer-abs.html"
- name="bug445004-outer-abs.html"></iframe>
- <iframe
- src="http://test1.example.org/tests/dom/html/test/bug445004-outer-abs.html"
- name="bug445004-outer-abs.html offsite"></iframe>
- <iframe
- src="http://example.org/tests/dom/html/test/bug445004-outer-write.html"
- name="bug445004-outer-write.html"></iframe>
- </p>
- </body>
- </html>
|