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

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

Issue 2799953002: Treat loads of invalid URLs as no-ops unless triggered by window.open. (Closed)
Patch Set: Created 3 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Adds event listeners and populates on-load-div. 5 // Adds event listeners and populates on-load-div.
6 window.onload = function() { 6 window.onload = function() {
7 updateOnLoadText('OnLoadText'); 7 updateOnLoadText('OnLoadText');
8 }; 8 };
9 9
10 var updateOnLoadText = function(text) { 10 var updateOnLoadText = function(text) {
11 document.getElementById('on-load-div').innerHTML = text; 11 document.getElementById('on-load-div').innerHTML = text;
12 } 12 }
13 13
14 var updateNoOpText = function() {
15 document.getElementById('no-op').innerHTML = 'NoOpText';
16 }
17
18 var buttonWasTapped = function() {
19 setTimeout(updateNoOpText, 500);
20 }
21
14 var isOnLoadTextVisible = function() { 22 var isOnLoadTextVisible = function() {
15 return document.getElementById('on-load-div').innerHTML == 'OnLoadText'; 23 return document.getElementById('on-load-div').innerHTML == 'OnLoadText';
16 } 24 }
17 25
26 var isNoOpTextVisible = function() {
27 return document.getElementById('no-op').innerHTML == 'NoOpText';
28 }
29
18 // Updates the url-to-load div with |text|. This value is later used by the 30 // Updates the url-to-load div with |text|. This value is later used by the
19 // window.location calls below. 31 // window.location calls below.
20 var updateUrlToLoadText = function(text) { 32 var updateUrlToLoadText = function(text) {
21 document.getElementById('url-to-load').innerHTML = text; 33 document.getElementById('url-to-load').innerHTML = text;
22 } 34 }
23 35
24 // Returns a DOMString representing the URL used as the innerHTML of the 36 // Returns a DOMString representing the URL used as the innerHTML of the
25 // url-to-load div. 37 // url-to-load div.
26 var getUrl = function() { 38 var getUrl = function() {
27 return document.getElementById('url-to-load').innerHTML; 39 return document.getElementById('url-to-load').innerHTML;
28 } 40 }
29 41
30 var locationAssign = function() { 42 var locationAssign = function() {
31 updateOnLoadText(''); 43 updateOnLoadText('');
32 window.location.assign(getUrl()); 44 window.location.assign(getUrl());
45 buttonWasTapped();
Eugene But (OOO till 7-30) 2017/04/06 18:34:19 |locationAssign| and other methods are named in ge
kkhorimoto 2017/04/07 00:03:40 Done.
33 } 46 }
34 47
35 var locationReplace = function() { 48 var locationReplace = function() {
36 updateOnLoadText(''); 49 updateOnLoadText('');
37 window.location.replace(getUrl()); 50 window.location.replace(getUrl());
51 buttonWasTapped();
38 } 52 }
39 53
40 var locationReload = function() { 54 var locationReload = function() {
41 updateOnLoadText(''); 55 updateOnLoadText('');
42 window.location.reload(); 56 window.location.reload();
57 buttonWasTapped();
43 } 58 }
44 59
45 var setLocationToDOMString = function() { 60 var setLocationToDOMString = function() {
46 updateOnLoadText(''); 61 updateOnLoadText('');
47 window.location = getUrl(); 62 window.location = getUrl();
63 buttonWasTapped();
48 } 64 }
49 65
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698