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

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 10053019: Add more diagnostic tracing when a JSON call doesn't return. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/pyauto.py
===================================================================
--- chrome/test/pyautolib/pyauto.py (revision 131795)
+++ chrome/test/pyautolib/pyauto.py (working copy)
@@ -935,7 +935,25 @@
return self._ui_test.ExecuteJavascriptInRenderView(script,
self.view,
self.frame_xpath)
+ def _GetResultFromJSONRequestDiagnostics(self):
Nirnimesh 2012/04/13 18:28:04 nit: need a blank line before this
+ """Same as _GetResultFromJSONRequest without throwing a timeout exception.
+ This method is used to diagnose if a command returns without causing a
+ timout exception to be thrown. This should be used for debugging purposes
+ only.
+
+ Returns:
+ True if the request returned; False if it timed out.
+ """
+ result = self._SendJSONRequest(-1,
+ json.dumps({'command': 'GetBrowserInfo',}),
+ self.action_max_timeout_ms())
+ if not result:
+ # The diagnostic command did not complete, Chrome is probably in a bad
+ # state
+ return False
+ return True
+
def _GetResultFromJSONRequest(self, cmd_dict, windex=0, timeout=-1):
"""Issue call over the JSON automation channel and fetch output.
@@ -971,14 +989,28 @@
additional_info = 'No information available.'
# Windows does not support os.kill until Python 2.7.
if not self.IsWin() and _BROWSER_PID:
- additional_info = ('The browser process ID %d still exists. '
- 'It is possible that it is hung.' % _BROWSER_PID)
+ browser_pid_exists = True
+ # Does the browser PID exist?
try:
# Does not actually kill the process
os.kill(int(_BROWSER_PID), 0)
except OSError:
- additional_info = ('The browser process ID %d no longer exists.' %
- _BROWSER_PID)
+ browser_pid_exists = False
+ if browser_pid_exists:
+ if self._GetResultFromJSONRequestDiagnostics():
+ # Browser info, worked, that means this hook had a problem
+ additional_info = ('The browser process ID %d still exists. '
+ 'PyAuto was able to get obtain browser info. It '
+ 'is possible this hook is broken.'
+ % _BROWSER_PID)
+ else:
+ additional_info = ('The browser process ID %d still exists. '
+ 'PyAuto was not able to obtain browser info. '
+ 'It is possible the browser is hung.'
+ % _BROWSER_PID)
+ else:
+ additional_info = ('The browser process ID %d no longer exists. '
+ 'Perhaps the browser crashed.' % _BROWSER_PID)
elif not _BROWSER_PID:
additional_info = ('The browser PID was not obtained. Does this test '
'have a unique startup configuration?')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698