Chromium Code Reviews| 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. |