docshell/test/test_bug413310.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=413310
     5 -->
     6 <head>
     7   <title>Test for Bug 413310</title>
     8   <script type="text/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=413310">Mozilla Bug 413310</a>
    13 <p id="display">
    14 <script class="testbody" type="text/javascript">
    16 if (navigator.platform.startsWith("Mac")) {
    17   SimpleTest.expectAssertions(0, 2);
    18 } else {
    19   SimpleTest.expectAssertions(0, 1);
    20 }
    22 /** Test for Bug 413310 **/
    24 // NOTE: If we ever make subframes do bfcache stuff, this test will need to be
    25 // modified accordingly!  It assumes that subframes do NOT get bfcached.
    26 var onloadCount = 0;
    28 var step = -1;  // One increment will come from the initial subframe onload.
    29                 // Note that this script should come before the subframe,
    30                 // so that doNextStep is defined when its onload handler fires.
    32 var textContent;
    34 SimpleTest.waitForExplicitFinish();
    36 addLoadEvent(doNextStep);
    38 function doNextStep() {
    39   ++step;
    40   switch (step) {
    41     case 1:
    42       is(onloadCount, 1, "Loaded initial page");
    43       is($("i").contentWindow.location.href,
    44          location.href.replace(/test_bug413310.html/,
    45                                "bug413310-subframe.html"),
    46          "Unexpected subframe location after initial load");
    47       $("i").contentDocument.forms[0].submit();
    48       break;
    49     case 2:
    50       is(onloadCount, 2, "Loaded POST result");
    52       is($("i").contentWindow.location.href,
    53          location.href.replace(/test_bug413310.html/,
    54                                "bug413310-post.sjs"),
    55          "Unexpected subframe location after POST load");
    57       textContent = $("i").contentDocument.body.textContent;
    58       isDeeply(textContent.match(/^POST /), ["POST "], "Not a POST?");
    60       $("i").contentWindow.location.hash = "foo";
    61       setTimeout(doNextStep, 0);
    62       break;
    63     case 3: 
    64       is(onloadCount, 2, "Anchor scroll should not fire onload");
    65       is($("i").contentWindow.location.href,
    66          location.href.replace(/test_bug413310.html/,
    67                                "bug413310-post.sjs#foo"),
    68          "Unexpected subframe location after anchor scroll");
    69       is(textContent, $("i").contentDocument.body.textContent,
    70          "Did a load when scrolling?");
    71       $("i").contentWindow.location.href = "bug413310-subframe.html";;
    72       break;
    73     case 4:
    74       is(onloadCount, 3, "Done new load");
    75       is($("i").contentWindow.location.href,
    76          location.href.replace(/test_bug413310.html/,
    77                                "bug413310-subframe.html"),
    78          "Unexpected subframe location after new load");
    79       history.back();
    80       break;
    81     case 5:
    82       is(onloadCount, 4,
    83          "History traversal didn't fire onload: bfcache issues!");
    84       is($("i").contentWindow.location.href,
    85          location.href.replace(/test_bug413310.html/,
    86                                "bug413310-post.sjs#foo"),
    87          "Unexpected subframe location");
    88       is(textContent, $("i").contentDocument.body.textContent,
    89          "Did a load when going back?");
    90       SimpleTest.finish();
    91       break;
    92   }
    93 }
    94 </script>
    95 <!-- Use a timeout in onload so that we don't do a load immediately inside onload -->
    96 <iframe id="i" src="bug413310-subframe.html" onload="setTimeout(doNextStep, 20)">
    97 </iframe>
    98 </p>
    99 <div id="content" style="display: none">
   101 </div>
   102 <pre id="test">
   103 </pre>
   104 </body>
   105 </html>

mercurial