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

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

Issue 10736055: Smoke test for tracing infrastructure in PyAuto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Smoke test for tracing infrastructure in PyAuto Created 8 years, 5 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
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index e388d80de784c8a387ec27b72441023d7eba8e30..959bd315ec6b2093b25548b82597f3d570bc66f5 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -3205,6 +3205,43 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
}
return self._GetResultFromJSONRequest(cmd_dict)
+ def ExecuteJavascriptWithFile(self, js, fileName, tab_index=0,
nduca 2012/07/18 05:51:35 Feels like this shoudl be a standalone changelist
+ windex=0, frame_xpath=''):
+ """Executes two scripts, one from a file, and one provided as an argument.
nduca 2012/07/18 05:51:35 Personally, this whole entry point feels kinda str
+
+ This function executes first the script loaded from "fileName", then the
+ script in the string "js" all within an anonymous function.
+
+ The execution occurrs by calling ExecuteJavascript.
+
+ Args:
+ fileName: filename of the script to load and execute
+ For other arguments, see ExecuteJavascript
+
+ Returns:
+ See ExecuteJavascript
+
+ Raises:
+ IOError if the file named by fileName cannot be found.
+ See ExecuteJavascript
+ """
+ fileJs, fd = (None, None)
+ try:
+ fd = open(fileName, "r")
+ fileJs = fd.read()
+ finally:
+ if( fd != None ):
nduca 2012/07/18 05:51:35 if fd: fd.close() shoudl work
+ fd.close()
+ return self.ExecuteJavascript("""
+ // Keep pollution down by eval'ing in an anonymous function.
+ (function(){
+ %s
+ %s
+ })();""" % (
+ fileJs,
+ js
+ ), tab_index, windex, frame_xpath)
+
def ExecuteJavascript(self, js, tab_index=0, windex=0, frame_xpath=''):
"""Executes a script in the specified frame of a tab.

Powered by Google App Engine
This is Rietveld 408576698