docshell/test/test_bug691547.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/test_bug691547.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=691547
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 691547</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +  <script type="application/javascript">
    1.14 +     var navStart = 0;
    1.15 +     var beforeReload = 0;
    1.16 +     function onContentLoad() {
    1.17 +       var frame = frames[0];
    1.18 +       if (!navStart) {
    1.19 +         // First time we perform navigation in subframe. The bug is that
    1.20 +         // load in subframe causes timing.navigationStart to be recorded
    1.21 +         // as if it was a start of the next navigation.
    1.22 +         var innerFrame = frame.frames[0];
    1.23 +         navStart = frame.performance.timing.navigationStart;
    1.24 +         innerFrame.location = 'bug570341_recordevents.html';
    1.25 +         // Let's wait a bit so the difference is clear anough.
    1.26 +         setTimeout(reload, 3000);
    1.27 +       } 
    1.28 +       else {
    1.29 +         // Content reloaded, time to check. We are allowing a huge time slack,
    1.30 +         // in case clock is imprecise. If we have a bug, the difference is 
    1.31 +         // expected to be about the timeout value set above.  
    1.32 +         var diff = frame.performance.timing.navigationStart - beforeReload;
    1.33 +         ok(diff >= -200,
    1.34 +            'navigationStart should be set after reload request. ' + 
    1.35 +            'Measured difference: ' + diff + ' (should be positive)');
    1.36 +         SimpleTest.finish();
    1.37 +       }
    1.38 +     }
    1.39 +     function reload() {
    1.40 +       var frame = frames[0];
    1.41 +       ok(navStart == frame.performance.timing.navigationStart,
    1.42 +          'navigationStart should not change when frame loads.');
    1.43 +       beforeReload = Date.now();
    1.44 +       frame.location.reload();
    1.45 +     }
    1.46 +  </script>
    1.47 +</head>
    1.48 +<body>
    1.49 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=570341">Mozilla Bug 570341</a>
    1.50 +<div id="frames">
    1.51 +<iframe name="frame0" id="frame0" src="bug691547_frame.html" onload="onContentLoad()"></iframe>
    1.52 +</div>
    1.53 +<div id="content" style="display: none">
    1.54 +
    1.55 +</div>
    1.56 +<pre id="test">
    1.57 +<script type="application/javascript">
    1.58 +SimpleTest.waitForExplicitFinish();
    1.59 +</script>
    1.60 +</pre>
    1.61 +</body>
    1.62 +</html>

mercurial