| <html> |
| <head> |
| <script> |
| |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| function startTest() { |
| location.hash = '#'; // Transitioning from no hash to an empty hash should not generate an event. |
| location.hash = '#someHash'; // This actually reflects a changed hash and should generate an event. |
| } |
| |
| function bodyInlineAttribute() |
| { |
| alert("<body> inline attribute called."); |
| document.body.onhashchange = bodyAssignedAttribute; |
| if (window.onhashchange != bodyAssignedAttribute) |
| alert("window.onhashchange should be the bodyAssignedAttribute() function, but isn't."); |
| if (document.body.onhashchange != window.onhashchange) |
| alert("document.body.onhashchange and window.onhashchange should be equal, but aren't."); |
| |
| location.hash = '#'; |
| } |
| |
| function bodyAssignedAttribute() |
| { |
| alert("<body> assigned attribute called."); |
| window.onhashchange = windowAttribute; |
| if (document.body.onhashchange != windowAttribute) |
| alert("document.body.onhashchange should be the windowAttribute() function, but isn't."); |
| if (document.body.onhashchange != window.onhashchange) |
| alert("document.body.onhashchange and window.onhashchange should be equal, but aren't."); |
| |
| location.hash = '#someHash'; |
| } |
| |
| function windowAttribute() |
| { |
| alert("window.onhashchange attribute called."); |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| </script> |
| </head> |
| <body onload="startTest();" onhashchange="bodyInlineAttribute();"> |
| <script> |
| if (document.body.onhashchange != window.onhashchange) |
| alert("document.body.onhashchange and window.onhashchange should be equal, but aren't."); |
| </script> |
| This test makes sure that the various methods of setting an onhashchange handler all work as expected.<br> |
| Clicking the links below manually should also result in the event being fired when the hash actually changes.<br> |
| <a href="#">Go to empty hash</a><br> |
| <a href="#someHash">Go to non-empty hash</a><br> |
| <a name="#">Empty hash anchor</a><br> |
| <a name="#someHash">Non-empty hash anchor</a> |
| </body> |
| </html> |