tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

file_bug668513.html (2968B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test file for Bug 668513</title>
      5 <script>
      6  var SimpleTest = opener.SimpleTest;
      7  var ok = opener.ok;
      8  var is = opener.is;
      9 
     10  function finish() {
     11    SimpleTest.finish();
     12    close();
     13  }
     14 
     15  function onload_test() {
     16    var win = frames[0];
     17    ok(win.performance, "Window.performance should be defined");
     18    ok(win.performance.navigation, "Window.performance.navigation should be defined");
     19    var navigation = win.performance && win.performance.navigation;
     20    if (navigation === undefined) {
     21      // avoid script errors
     22      finish();
     23      return;
     24    }
     25 
     26    // do this with a timeout to see the visuals of the navigations.
     27    setTimeout(nav_frame, 100);
     28  }
     29 
     30  var step = 1;
     31  function nav_frame() {
     32    var navigation_frame = frames[0];
     33    var navigation = navigation_frame.performance.navigation;
     34    switch (step) {
     35      case 1:
     36      {
     37        navigation_frame.location.href = "bug570341_recordevents.html";
     38        step++;
     39        break;
     40      }
     41      case 2:
     42      {
     43        is(navigation.type, navigation.TYPE_NAVIGATE,
     44           "Expected window.performance.navigation.type == TYPE_NAVIGATE");
     45        navigation_frame.history.back();
     46        step++;
     47        break;
     48      }
     49      case 3:
     50      {
     51        is(navigation.type, navigation.TYPE_BACK_FORWARD,
     52           "Expected window.performance.navigation.type == TYPE_BACK_FORWARD");
     53        step++;
     54        navigation_frame.history.forward();
     55        break;
     56      }
     57      case 4:
     58      {
     59        is(navigation.type, navigation.TYPE_BACK_FORWARD,
     60           "Expected window.performance.navigation.type == TYPE_BACK_FORWARD");
     61        navigation_frame.location.href = "bug668513_redirect.html";
     62        step++;
     63        break;
     64      }
     65      case 5:
     66      {
     67        is(navigation.type, navigation.TYPE_NAVIGATE,
     68           "Expected timing.navigation.type as TYPE_NAVIGATE");
     69        is(navigation.redirectCount, 1,
     70           "Expected navigation.redirectCount == 1 on an server redirected navigation");
     71 
     72        var timing = navigation_frame.performance && navigation_frame.performance.timing;
     73        if (timing === undefined) {
     74          // avoid script errors
     75          finish();
     76          break;
     77        }
     78        ok(timing.navigationStart > 0, "navigationStart should be > 0");
     79        var sequence = ["navigationStart", "redirectStart", "redirectEnd", "fetchStart"];
     80        for (var j = 1; j < sequence.length; ++j) {
     81          var prop = sequence[j];
     82          var prevProp = sequence[j - 1];
     83          ok(timing[prevProp] <= timing[prop],
     84             ["Expected ", prevProp, " to happen before ", prop,
     85              ", got ", prevProp, " = ", timing[prevProp],
     86              ", ", prop, " = ", timing[prop]].join(""));
     87        }
     88        step++;
     89        finish();
     90        break;
     91      }
     92    }
     93  }
     94 </script>
     95 </head>
     96 <body>
     97 <div id="frames">
     98 <iframe name="child0" onload="onload_test();" src="navigation/blank.html"></iframe>
     99 </div>
    100 </body>
    101 </html>