Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: ios/testing/data/http_server_files/history_go.js

Issue 2569503002: Created test page to be used for window.history.go() tests. (Closed)
Patch Set: fix goBack2 Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/testing/data/http_server_files/history_go.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « ios/testing/data/http_server_files/history_go.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698