Commit 97c65878 authored by kkhorimoto's avatar kkhorimoto Committed by Commit bot

Add functionality to window.history.go test page.

- Added back/forward buttons.
- Added pushState() button.  This is necessary because if the pushState
  call is executed by injected JavaScript, then the navigation is
  registered as a client redirect.
- Display placeholder state object string when a popstate event with a
  null state object is received.

BUG=673022

Review-Url: https://codereview.chromium.org/2583733002
Cr-Commit-Position: refs/heads/master@{#439020}
parent dfa33876
......@@ -27,10 +27,16 @@ found in the LICENSE file. -->
onclick="goNoParameter()" /><br>
<input type="button" value="go-zero" id="go-zero"
onclick="goZero()" /><br>
<input type="button" value="go-back" id="go-back"
onclick="goBack()" /><br>
<input type="button" value="go-forward" id="go-forward"
onclick="goForward()" /><br>
<input type="button" value="go-2" id="go-2"
onclick="go2()" /><br>
<input type="button" value="go-back-2" id="go-back-2"
onclick="goBack2()" /><br>
<input type="button" value="push-state-with-hash" id="push-state-with-hash"
onclick="pushStateWithHash()" /><br>
</body>
</html>
......@@ -12,7 +12,8 @@ window.onload = function() {
// Populates pop-state-received-div and state-object-div upon a popstate event.
var onPopstate = function(e) {
updatePopStateReceivedText(true);
updateStateObjectText(e.state);
var stateText = e.state ? e.state : '(NO STATE OBJECT)';
updateStateObjectText(stateText);
};
// Populates hash-change-received-div upon receiving of a hashchange event.
......@@ -64,6 +65,16 @@ var goZero = function() {
window.history.go(0);
}
var goBack = function() {
onButtonTapped();
window.history.back();
}
var goForward = function() {
onButtonTapped();
window.history.forward();
}
var go2 = function() {
onButtonTapped();
window.history.go(2);
......@@ -73,3 +84,8 @@ var goBack2 = function() {
onButtonTapped();
window.history.go(-2);
}
var pushStateWithHash = function() {
onButtonTapped();
window.history.pushState('STATE_OBJECT', 'Title', '#hash');
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment