| Index: ios/testing/data/http_server_files/history_go.js
|
| diff --git a/ios/testing/data/http_server_files/history_go.js b/ios/testing/data/http_server_files/history_go.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..543f18649e8ca43edf8f9b41db16cee7f6b58f96
|
| --- /dev/null
|
| +++ b/ios/testing/data/http_server_files/history_go.js
|
| @@ -0,0 +1,75 @@
|
| +// 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);
|
| +}
|
|
|