| OLD | NEW |
| (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 isOnLoadPlaceholderTextVisible = function() { |
| 20 return document.getElementById('on-load').innerHTML == 'OnLoadText'; |
| 21 } |
| 22 |
| 23 var isNoOpPlaceholderTextVisible = function() { |
| 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 // Clears div text so tests can verify that the reported values are the result |
| 42 // of the latest executed script. |
| 43 var onButtonTapped = function() { |
| 44 updateOnLoadText(''); |
| 45 updateNoOpText(''); |
| 46 setTimeout(onNoOpTimeout, 500); |
| 47 } |
| 48 |
| 49 var pushStateAction = function() { |
| 50 onButtonTapped(); |
| 51 window.history.pushState(gStateParams.obj, gStateParams.title, |
| 52 gStateParams.url); |
| 53 } |
| 54 |
| 55 var replaceStateAction = function() { |
| 56 onButtonTapped(); |
| 57 window.history.replaceState(gStateParams.obj, gStateParams.title, |
| 58 gStateParams.url); |
| 59 } |
| 60 |
| OLD | NEW |