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

Side by Side Diff: ios/testing/data/http_server_files/state_operations.js

Issue 2601193003: Created a test page for window.history.[push/replace]State() tests. (Closed)
Patch Set: Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Populates onload text and clear no-op text.
6 window.onload = function() {
7 updateOnLoadText('OnLoadText');
8 updateNoOpText('');
9 };
10
11 var updateOnLoadText = function(text) {
12 document.getElementById('on-load').innerHTML = text;
13 }
14
15 var updateNoOpText = function(text) {
16 document.getElementById('no-op').innerHTML = text;
17 }
18
19 var isOnLoadTextVisible = function() {
Eugene But (OOO till 7-30) 2017/01/20 21:55:04 This name makes me think that result is true if te
kkhorimoto 2017/01/21 01:38:24 Changed to isOnLoadPlaceholderTextVisible.
20 return document.getElementById('on-load').innerHTML == 'OnLoadText';
21 }
22
23 var isNoOpTextVisible = function() {
Eugene But (OOO till 7-30) 2017/01/20 21:55:04 ditto
kkhorimoto 2017/01/21 01:38:24 Done.
24 return document.getElementById('no-op').innerHTML == 'NoOpText';
25 }
26
27 // When a button is tapped, a 0,5s timeout begins that will call this function.
28 var onNoOpTimeout = function() {
29 document.getElementById('no-op').innerHTML = 'NoOpText';
30 }
31
32 // Updates |gStateParams| to hold the specified values. These are later used as
33 // input parameters to history state changes.
34 var gStateParams = {};
35 var updateStateParams = function(obj, title, url) {
36 gStateParams.obj = obj;
37 gStateParams.title = title;
38 gStateParams.url = url;
39 }
40
41 // Returns whether the input parameters are reflected in |gStateParams|.
42 var checkStateParams = function(obj, title, url) {
43 return gStateParams.obj == obj &&
44 gStateParams.title == title &&
45 gStateParams.url == url;
46 }
47
48 // Clears div text so tests can verify that the reported values are the result
49 // of the latest executed script.
50 var onButtonTapped = function() {
51 updateOnLoadText('');
52 updateNoOpText('');
53 setTimeout(onNoOpTimeout, 500);
54 }
55
56 var pushStateAction = function() {
57 onButtonTapped();
58 window.history.pushState(gStateParams.obj, gStateParams.title,
59 gStateParams.url);
60 }
61
62 var replaceStateAction = function() {
63 onButtonTapped();
64 window.history.replaceState(gStateParams.obj, gStateParams.title,
65 gStateParams.url);
66 }
67
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698