no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / mochitest / test_bug640387_2.html
blobc248a64836087744cc94daa11d02cf65f3da2b0e
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 src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script 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 <!-- Test that, when going from
17 http://example.com/#foo
21 http://example.com/
23 via a non-history load, we do a true load, rather than a scroll. -->
25 <script type='application/javascript'>
26 SimpleTest.waitForExplicitFinish();
28 var callbackOnLoad = false;
29 function childLoad() {
30 if (callbackOnLoad) {
31 callbackOnLoad = false;
32 gGen.next();
36 var errorOnHashchange = false;
37 var callbackOnHashchange = false;
38 function childHashchange() {
39 if (errorOnHashchange) {
40 ok(false, "Got unexpected hashchange.");
42 if (callbackOnHashchange) {
43 callbackOnHashchange = false;
44 gGen.next();
48 function* run_test() {
49 var iframe = $("iframe").contentWindow;
51 ok(true, "Got first load");
53 // Spin the event loop so we exit the onload handler.
54 SimpleTest.executeSoon(function() { gGen.next(); });
55 yield undefined;
57 let origLocation = iframe.location + "";
58 callbackOnHashchange = true;
59 iframe.location.hash = "#1";
60 // Wait for a hashchange event.
61 yield undefined;
63 ok(true, "Got hashchange.");
65 iframe.location = origLocation;
66 // This should produce a load event and *not* a hashchange, because the
67 // result of the load is a different document than we had previously.
68 callbackOnLoad = true;
69 errorOnHashchange = true;
70 yield undefined;
72 ok(true, "Got final load.");
74 // Spin the event loop to give hashchange a chance to fire, if it's going to.
75 SimpleTest.executeSoon(function() { gGen.next(); });
76 yield undefined;
78 SimpleTest.finish();
81 callbackOnLoad = true;
82 var gGen = run_test();
84 </script>
86 <iframe id='iframe' src='file_bug640387.html'></iframe>
88 </body>
89 </html>