docshell/test/test_bug640387_1.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=640387
     5 -->
     6 <head>
     7   <title>Test for Bug 640387</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=640387">Mozilla Bug 640387</a>
    15 <script type='application/javascript;version=1.7'>
    16 SimpleTest.waitForExplicitFinish();
    18 function test() {
    19   /* Spin the event loop so we get out of the onload handler. */
    20   SimpleTest.executeSoon(function() { gGen.next() });
    21   yield undefined;
    23   popup.history.pushState('', '', '#hash1');
    24   popup.history.pushState('', '', '#hash2');
    26   // Now the history looks like:
    27   //   file_bug640387.html
    28   //   file_bug640387.html#hash1
    29   //   file_bug640387.html#hash2  <-- current
    31   // Going back should trigger a hashchange, which will wake us up from the
    32   // yield.
    33   popup.history.back();
    34   yield undefined;
    35   ok(true, 'Got first hashchange.');
    37   // Going back should wake us up again.
    38   popup.history.back();
    39   yield undefined;
    40   ok(true, 'Got second hashchange.');
    42   // Now the history looks like:
    43   //   file_bug640387.html        <-- current
    44   //   file_bug640387.html#hash1
    45   //   file_bug640387.html#hash2
    47   // Going forward should trigger a hashchange.
    48   popup.history.forward();
    49   yield undefined;
    50   ok(true, 'Got third hashchange.');
    52   // Now modify the history so it looks like:
    53   //   file_bug640387.html
    54   //   file_bug640387.html#hash1
    55   //   file_bug640387.html#hash1  <-- current
    56   popup.history.pushState('', '', '#hash1');
    58   // Now when we go back, we should not get a hashchange.  Instead, wait for a
    59   // popstate.  We need to asynchronously go back because popstate is fired
    60   // sync.
    61   gHashchangeExpected = false;
    62   gCallbackOnPopstate = true;
    63   SimpleTest.executeSoon(function() { popup.history.back() });
    64   yield undefined;
    65   ok(true, 'Got popstate.');
    66   gCallbackOnPopstate = false;
    68   // Spin the event loop so hashchange has a chance to fire, if it's going to.
    69   SimpleTest.executeSoon(function() { gGen.next() });
    70   yield undefined;
    72   popup.close();
    73   SimpleTest.finish();
    74   yield undefined;
    75 }
    77 gGen = null;
    78 function childLoad() {
    79   gGen = test();
    80   gGen.next();
    81 }
    83 gHashchangeExpected = true;
    84 function childHashchange() {
    85   if (gHashchangeExpected) {
    86     gGen.next();
    87   }
    88   else {
    89     ok(false, "Got hashchange when we weren't expecting one.");
    90   }
    91 }
    93 gCallbackOnPopstate = false;
    94 function childPopstate() {
    95   if (gCallbackOnPopstate) {
    96     gGen.next();
    97   }
    98 }
   100 /* We need to run this test in a popup, because navigating an iframe
   101  * back/forwards tends to cause intermittent orange. */
   102 popup = window.open('file_bug640387.html');
   104 /* Control now flows up to childLoad(), called once the popup loads. */
   106 </script>
   108 </body>
   109 </html>

mercurial