| // 2- loads this page + hash (doesn't call onload) |
| // 3- loads a data URL that just navigates back |
| // 4- loads this page + hash (calls onload, triggering completion) |
| function navigateToHash(field) { |
| function navigateAwayAndBack() { |
| // Assigning to location does not create a history entry, so |
| // instead we simulate a link click. |
| var evt = document.createEvent("MouseEvents"); |
| evt.initMouseEvent("click", true, true, window, |
| 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
| document.getElementById('anchor').dispatchEvent(evt); |
| var hash = location.hash; |
| var field = document.getElementById('field'); |
| testRunner.waitUntilDone(); |
| // Location changes need to happen outside the onload handler to generate history entries. |
| document.body.innerHTML = (field.value == '') ? 'FAIL' : 'PASS'; |
| <body onload='runTestStep()' onunload='/*suppress page cache*/'> |
| <input id='field'></input> |
| <a id='anchor' href='data:text/html,<body onload="history.back()"></body>'>go away and come back</a> |