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

Side by Side Diff: tools/telemetry/telemetry/core/util.py

Issue 20672002: [telemetry] Add a webdriver backend with support for IE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 7 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 import inspect 4 import inspect
5 import os 5 import os
6 import socket 6 import socket
7 import time 7 import time
8 8
9 class TimeoutException(Exception): 9 class TimeoutException(Exception):
10 pass 10 pass
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 var _element = _findElement(document, \"""" + text + """\"); 63 var _element = _findElement(document, \"""" + text + """\");
64 return callback_function(_element); 64 return callback_function(_element);
65 })();""" 65 })();"""
66 return tab.EvaluateJavaScript(code) 66 return tab.EvaluateJavaScript(code)
67 67
68 class PortPair(object): 68 class PortPair(object):
69 def __init__(self, local_port, remote_port): 69 def __init__(self, local_port, remote_port):
70 self.local_port = local_port 70 self.local_port = local_port
71 self.remote_port = remote_port 71 self.remote_port = remote_port
72 72
73 class DoNothingForwarder(object):
74 def __init__(self, *port_pairs):
75 self._host_port = port_pairs[0].local_port
76
77 @property
78 def url(self):
79 assert self._host_port
80 return 'http://127.0.0.1:%i' % self._host_port
81
82 def Close(self):
83 self._host_port = None
84
73 def GetAvailableLocalPort(): 85 def GetAvailableLocalPort():
74 tmp = socket.socket() 86 tmp = socket.socket()
75 tmp.bind(('', 0)) 87 tmp.bind(('', 0))
76 port = tmp.getsockname()[1] 88 port = tmp.getsockname()[1]
77 tmp.close() 89 tmp.close()
78 90
79 return port 91 return port
80 92
81 def CloseConnections(tab): 93 def CloseConnections(tab):
82 """Closes all TCP sockets held open by the browser.""" 94 """Closes all TCP sockets held open by the browser."""
83 try: 95 try:
84 tab.ExecuteJavaScript("""window.chrome && chrome.benchmarking && 96 tab.ExecuteJavaScript("""window.chrome && chrome.benchmarking &&
85 chrome.benchmarking.closeConnections()""") 97 chrome.benchmarking.closeConnections()""")
86 except Exception: 98 except Exception:
87 pass 99 pass
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698