Commit 4fe55265 authored by kkhorimoto's avatar kkhorimoto Committed by Commit bot

Created test page to be used for window.history.go() tests.

BUG=673022

Review-Url: https://codereview.chromium.org/2569503002
Cr-Commit-Position: refs/heads/master@{#438031}
parent 2b649d03
...@@ -67,6 +67,8 @@ bundle_data("http_server_bundle_data") { ...@@ -67,6 +67,8 @@ bundle_data("http_server_bundle_data") {
"data/http_server_files/fullscreen.html", "data/http_server_files/fullscreen.html",
"data/http_server_files/history.html", "data/http_server_files/history.html",
"data/http_server_files/history.js", "data/http_server_files/history.js",
"data/http_server_files/history_go.html",
"data/http_server_files/history_go.js",
"data/http_server_files/memory_usage.html", "data/http_server_files/memory_usage.html",
"data/http_server_files/multi_field_form.html", "data/http_server_files/multi_field_form.html",
"data/http_server_files/pony.html", "data/http_server_files/pony.html",
......
<!DOCTYPE html>
<!-- Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>History navigation</title>
<script type="text/javascript" src="history_go.js"></script>
</head>
<body>
<p></p>
<div id='on-load-div'></div>
<br>
<div id='no-op-div'></div>
<br>
<div id='pop-state-received-div'></div>
<br>
<div id='state-object-div'></div>
<br>
<div id='hash-change-received-div'></div>
</p>
<input type="button" value="go-no-parameter" id="go-no-parameter"
onclick="goNoParameter()" /><br>
<input type="button" value="go-zero" id="go-zero"
onclick="goZero()" /><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>
</body>
</html>
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Adds event listeners and populates on-load-div.
window.onload = function() {
window.addEventListener('popstate', onPopstate);
window.addEventListener('hashchange', onHashChange);
updateOnLoadText('OnLoadText');
};
// Populates pop-state-received-div and state-object-div upon a popstate event.
var onPopstate = function(e) {
updatePopStateReceivedText(true);
updateStateObjectText(e.state);
};
// Populates hash-change-received-div upon receiving of a hashchange event.
var onHashChange = function(e) {
updateHashChangeReceivedText(true);
}
var updateOnLoadText = function(text) {
document.getElementById('on-load-div').innerHTML = text;
}
var updateNoOpText = function(text) {
document.getElementById('no-op-div').innerHTML = text;
}
var updatePopStateReceivedText = function(received) {
var text = received ? 'PopStateReceived' : '';
document.getElementById('pop-state-received-div').innerHTML = text;
}
var updateStateObjectText = function(state) {
document.getElementById('state-object-div').innerHTML = state;
}
var updateHashChangeReceivedText = function(received) {
var text = received ? 'HashChangeReceived' : '';
document.getElementById('hash-change-received-div').innerHTML = text;
}
// Clears all div text an starts a timer that updates no-op-div with "NoOpText"
// after 1s. This allows tests to verify that no nagivations occur after a
// no-op JavaScript call.
var onButtonTapped = function() {
updateOnLoadText('');
updateNoOpText('');
updatePopStateReceivedText(false);
updateStateObjectText('');
updateHashChangeReceivedText(false);
setTimeout("updateNoOpText('NoOpText')", 1000);
}
var goNoParameter = function() {
onButtonTapped();
window.history.go();
}
var goZero = function() {
onButtonTapped();
window.history.go(0);
}
var go2 = function() {
onButtonTapped();
window.history.go(2);
}
var goBack2 = function() {
onButtonTapped();
window.history.go(-2);
}
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