content/html/document/test/test_bug445004.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=445004
     5 -->
     6 <head>
     7   <title>Test for Bug 445004</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=445004">Mozilla Bug 445004</a>
    13 <div id="content" style="display: none">
    15 </div>
    16 <pre id="test">
    17 <script type="application/javascript">
    19 /** Test for Bug 445004 **/
    20 is(window.location.hostname, "mochi.test", "Unexpected hostname");
    21 is(window.location.port, "8888", "Unexpected port; fix testcase");
    23 SimpleTest.waitForExplicitFinish();
    25 var loads = 1;
    27 function loadStarted() {
    28   ++loads;
    29 }
    30 function loadEnded() {
    31   --loads;
    32   if (loads == 0) {
    33     doTest();
    34   }
    35 }
    37 window.onload = loadEnded;
    39 function getMessage(evt) {
    40   ok(evt.data == "start" || evt.data == "end", "Must have start or end");
    41   if (evt.data == "start")
    42     loadStarted();
    43   else
    44     loadEnded();
    45 }
    47 window.addEventListener("message", getMessage, false);
    49 function checkURI(uri, name, type) {
    50   var host = uri.match(/^http:\/\/([a-z.0-9]*)/)[1];
    51   var file = uri.match(/([^\/]*).png$/)[1];
    52   is(host, file, "Unexpected base URI for test " + name +
    53      " when testing " + type);
    54 }
    56 function checkFrame(num) {
    57   // Just snarf our data
    58   var outer = SpecialPowers.wrap(window.frames[num]);
    59   name = outer.name;
    61   is(outer.document.baseURI,
    62      "http://example.org/tests/content/html/document/test/bug445004-outer.html",
    63      "Unexpected base URI for " + name);
    65   var iswrite = name.match(/write/);
    67   var inner = outer.frames[0];
    68   if (iswrite) {
    69     is(inner.document.baseURI,
    70        "http://example.org/tests/content/html/document/test/bug445004-outer.html",
    71        "Unexpected inner base URI for " + name);
    72   } else {
    73     is(inner.document.baseURI,
    74        "http://test1.example.org/tests/content/html/document/test/bug445004-inner.html",
    75        "Unexpected inner base URI for " + name);
    76   }
    78   var isrel = name.match(/rel/);
    79   var offsite = name.match(/offsite/);
    81   if (!iswrite) {
    82     if ((isrel && !offsite) || (!isrel && offsite)) {
    83       is(inner.location.hostname, outer.location.hostname,
    84          "Unexpected hostnames for " + name);
    85     } else {
    86       isnot(inner.location.hostname, outer.location.hostname,
    87             "Unexpected hostnames for " + name);
    88     }
    89   }
    91   checkURI(inner.frames[0].location.href, name, "direct location");
    92   checkURI(inner.frames[1].document.getElementsByTagName("img")[0].src,
    93            name, "direct write");
    94   if (!iswrite) {
    95     is(inner.frames[1].location.hostname, inner.location.hostname,
    96        "Incorrect hostname for " + name + " direct write")
    97   }
    98   checkURI(inner.frames[2].location.href, name, "indirect location");
    99   checkURI(inner.frames[3].document.getElementsByTagName("img")[0].src,
   100            name, "indirect write");
   101   if (!iswrite) {
   102     is(inner.frames[3].location.hostname, outer.location.hostname,
   103        "Incorrect hostname for " + name + " indirect write")
   104   }
   105   checkURI(inner.document.getElementsByTagName("img")[0].src,
   106            name, "direct image load");
   107 }
   110 function doTest() {
   111   for (var num = 0; num < 5; ++num) {
   112     checkFrame(num);
   113   }
   115   SimpleTest.finish();
   116 }
   118 </script>
   119 </pre>
   120 <p id="display">
   121   <iframe
   122      src="http://example.org/tests/content/html/document/test/bug445004-outer-rel.html"
   123      name="bug445004-outer-rel.html"></iframe>
   124   <iframe
   125      src="http://test1.example.org/tests/content/html/document/test/bug445004-outer-rel.html"
   126      name="bug445004-outer-rel.html offsite"></iframe>
   127   <iframe
   128      src="http://example.org/tests/content/html/document/test/bug445004-outer-abs.html"
   129      name="bug445004-outer-abs.html"></iframe>
   130   <iframe
   131      src="http://test1.example.org/tests/content/html/document/test/bug445004-outer-abs.html"
   132      name="bug445004-outer-abs.html offsite"></iframe>
   133   <iframe
   134      src="http://example.org/tests/content/html/document/test/bug445004-outer-write.html"
   135      name="bug445004-outer-write.html"></iframe>
   136 </p>
   137 </body>
   138 </html>

mercurial