content/base/test/file_bug426646-2.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 <html><head>
     2 <title>Bug 426646, Using location.replace breaks iframe history</title>
     3 <script type="text/javascript">
     4 var url1 = "data:text/html;charset=utf-8,1st%20page";
     6 var win0 = null;
     8 function soon(f) {
     9   return function() { setTimeout(f, 0); };
    10 }
    12 function doe() {
    13   document.body.innerHTML = "<iframe src='about:blank'></iframe>";
    14   document.body.innerHTML += "<iframe src='about:blank'></iframe>";
    15   win0 = window.frames[0];
    16   win0.frameElement.onload = soon(doe2);
    17   win0.location.replace(url1);
    18 }
    20 function doe2() {
    21   // Add some iframes/docshells. Session history should still work.
    22   var ifr1 = document.createElement("iframe");
    23   document.body.insertBefore(ifr1, document.body.firstChild);
    24   ifr1.onload = soon(doe3);
    26   var ifr2 = document.createElement("iframe");
    27   document.body.insertBefore(ifr2, document.body.firstChild);
    28   ifr2.onload = soon(doe3);
    30   var ifr3 = document.createElement("iframe");
    31   document.body.insertBefore(ifr3, document.body.firstChild);
    32   ifr3.onload = soon(doe3);
    33 }
    35 var doe3_count = 0;
    36 function doe3() {
    37   // Wait until all three iframes have loaded about:blank before navigating
    38   // win0.
    39   doe3_count++;
    40   if (doe3_count < 3) {
    41     return;
    42   }
    43   if (doe3_count > 3) {
    44     ok(false, 'Unexpected ' + doe3_count + 'th call to doe3.');
    45     return;
    46   }
    48   win0.frameElement.onload = soon(doe4);
    49   win0.location = 'data:text/html;charset=utf-8,2nd%20page';
    50 }
    52 function doe4() {
    53   win0.frameElement.onload = soon(doe5);
    54   history.go(-1);
    55 }
    57 function doe5() {
    58   opener.is(win0.location, url1, "History.go(-1) didn't work?");
    59   close();
    60 }
    61 </script>
    62 </head>
    63 <body onload="setTimeout(doe, 0);" onunload="opener.nextTest();">
    64 </body></html>

mercurial