docshell/test/test_bug640387_2.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/test_bug640387_2.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,90 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=640387
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 640387</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=640387">Mozilla Bug 640387</a>
    1.17 +
    1.18 +<!-- Test that, when going from
    1.19 +
    1.20 +  http://example.com/#foo
    1.21 +
    1.22 +to
    1.23 +
    1.24 +  http://example.com/
    1.25 +
    1.26 +via a non-history load, we do a true load, rather than a scroll. -->
    1.27 +
    1.28 +<script type='application/javascript;version=1.7'>
    1.29 +SimpleTest.waitForExplicitFinish();
    1.30 +
    1.31 +callbackOnLoad = false;
    1.32 +function childLoad() {
    1.33 +  if (callbackOnLoad) {
    1.34 +    callbackOnLoad = false;
    1.35 +    gGen.next();
    1.36 +  }
    1.37 +}
    1.38 +
    1.39 +errorOnHashchange = false;
    1.40 +callbackOnHashchange = false;
    1.41 +function childHashchange() {
    1.42 +  if (errorOnHashchange) {
    1.43 +    ok(false, 'Got unexpected hashchange.');
    1.44 +  }
    1.45 +  if (callbackOnHashchange) {
    1.46 +    callbackOnHashchange = false;
    1.47 +    gGen.next();
    1.48 +  }
    1.49 +}
    1.50 +
    1.51 +function run_test() {
    1.52 +  var iframe = $('iframe').contentWindow;
    1.53 +
    1.54 +  ok(true, 'Got first load');
    1.55 +
    1.56 +  // Spin the event loop so we exit the onload handler.
    1.57 +  SimpleTest.executeSoon(function() { gGen.next() });
    1.58 +  yield undefined;
    1.59 +
    1.60 +  let origLocation = iframe.location + '';
    1.61 +  callbackOnHashchange = true;
    1.62 +  iframe.location.hash = '#1';
    1.63 +  // Wait for a hashchange event.
    1.64 +  yield undefined;
    1.65 +
    1.66 +  ok(true, 'Got hashchange.');
    1.67 +
    1.68 +  iframe.location = origLocation;
    1.69 +  // This should produce a load event and *not* a hashchange, because the
    1.70 +  // result of the load is a different document than we had previously.
    1.71 +  callbackOnLoad = true;
    1.72 +  errorOnHashchange = true;
    1.73 +  yield undefined;
    1.74 +
    1.75 +  ok(true, 'Got final load.');
    1.76 +
    1.77 +  // Spin the event loop to give hashchange a chance to fire, if it's going to.
    1.78 +  SimpleTest.executeSoon(function() { gGen.next() });
    1.79 +  yield undefined;
    1.80 +
    1.81 +  SimpleTest.finish();
    1.82 +  yield undefined;
    1.83 +}
    1.84 +
    1.85 +callbackOnLoad = true;
    1.86 +gGen = run_test();
    1.87 +
    1.88 +</script>
    1.89 +
    1.90 +<iframe id='iframe' src='file_bug640387.html'></iframe>
    1.91 +
    1.92 +</body>
    1.93 +</html>

mercurial