|
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> |
|
14 |
|
15 <!-- Test that, when going from |
|
16 |
|
17 http://example.com/#foo |
|
18 |
|
19 to |
|
20 |
|
21 http://example.com/ |
|
22 |
|
23 via a non-history load, we do a true load, rather than a scroll. --> |
|
24 |
|
25 <script type='application/javascript;version=1.7'> |
|
26 SimpleTest.waitForExplicitFinish(); |
|
27 |
|
28 callbackOnLoad = false; |
|
29 function childLoad() { |
|
30 if (callbackOnLoad) { |
|
31 callbackOnLoad = false; |
|
32 gGen.next(); |
|
33 } |
|
34 } |
|
35 |
|
36 errorOnHashchange = false; |
|
37 callbackOnHashchange = false; |
|
38 function childHashchange() { |
|
39 if (errorOnHashchange) { |
|
40 ok(false, 'Got unexpected hashchange.'); |
|
41 } |
|
42 if (callbackOnHashchange) { |
|
43 callbackOnHashchange = false; |
|
44 gGen.next(); |
|
45 } |
|
46 } |
|
47 |
|
48 function run_test() { |
|
49 var iframe = $('iframe').contentWindow; |
|
50 |
|
51 ok(true, 'Got first load'); |
|
52 |
|
53 // Spin the event loop so we exit the onload handler. |
|
54 SimpleTest.executeSoon(function() { gGen.next() }); |
|
55 yield undefined; |
|
56 |
|
57 let origLocation = iframe.location + ''; |
|
58 callbackOnHashchange = true; |
|
59 iframe.location.hash = '#1'; |
|
60 // Wait for a hashchange event. |
|
61 yield undefined; |
|
62 |
|
63 ok(true, 'Got hashchange.'); |
|
64 |
|
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; |
|
71 |
|
72 ok(true, 'Got final load.'); |
|
73 |
|
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; |
|
77 |
|
78 SimpleTest.finish(); |
|
79 yield undefined; |
|
80 } |
|
81 |
|
82 callbackOnLoad = true; |
|
83 gGen = run_test(); |
|
84 |
|
85 </script> |
|
86 |
|
87 <iframe id='iframe' src='file_bug640387.html'></iframe> |
|
88 |
|
89 </body> |
|
90 </html> |