| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 import pyauto_functional | 10 import pyauto_functional |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 self.NavigateToURL(self.GetFileURLForDataPath( | 30 self.NavigateToURL(self.GetFileURLForDataPath( |
| 31 'frame_dom_access', 'frame_dom_access.html')) | 31 'frame_dom_access', 'frame_dom_access.html')) |
| 32 | 32 |
| 33 v = self.GetDOMValue('document.getElementById("myinput").nodeName') | 33 v = self.GetDOMValue('document.getElementById("myinput").nodeName') |
| 34 self.assertEqual(v, 'INPUT') | 34 self.assertEqual(v, 'INPUT') |
| 35 | 35 |
| 36 def testExecuteJavascriptInExtension(self): | 36 def testExecuteJavascriptInExtension(self): |
| 37 """Test we can inject JavaScript into an extension.""" | 37 """Test we can inject JavaScript into an extension.""" |
| 38 dir_path = os.path.abspath( | 38 dir_path = os.path.abspath( |
| 39 os.path.join(self.DataDir(), 'extensions', 'js_injection_background')) | 39 os.path.join(self.DataDir(), 'extensions', 'js_injection_background')) |
| 40 ext_id = self.InstallExtension(dir_path, False); | 40 ext_id = self.InstallExtension(dir_path) |
| 41 self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) | 41 self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) |
| 42 | 42 |
| 43 # Verify extension is enabled. | 43 # Verify extension is enabled. |
| 44 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 44 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
| 45 self.assertTrue(extension['is_enabled'], | 45 self.assertTrue(extension['is_enabled'], |
| 46 msg='Extension was disabled by default') | 46 msg='Extension was disabled by default') |
| 47 | 47 |
| 48 # Get the background page's view. | 48 # Get the background page's view. |
| 49 background_view = self.WaitUntilExtensionViewLoaded( | 49 background_view = self.WaitUntilExtensionViewLoaded( |
| 50 view_type='EXTENSION_BACKGROUND_PAGE') | 50 view_type='EXTENSION_BACKGROUND_PAGE') |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 v = self.ExecuteJavascriptInRenderView( | 64 v = self.ExecuteJavascriptInRenderView( |
| 65 'window.domAutomationController.send(int_var)', background_view) | 65 'window.domAutomationController.send(int_var)', background_view) |
| 66 self.assertEqual(v, 42, msg='Incorrect value returned (v = %s).' % v) | 66 self.assertEqual(v, 42, msg='Incorrect value returned (v = %s).' % v) |
| 67 v = self.ExecuteJavascriptInRenderView( | 67 v = self.ExecuteJavascriptInRenderView( |
| 68 'window.domAutomationController.send(str_var)', background_view) | 68 'window.domAutomationController.send(str_var)', background_view) |
| 69 self.assertEqual(v, 'foo', msg='Incorrect value returned (v = %s).' % v) | 69 self.assertEqual(v, 'foo', msg='Incorrect value returned (v = %s).' % v) |
| 70 | 70 |
| 71 | 71 |
| 72 if __name__ == '__main__': | 72 if __name__ == '__main__': |
| 73 pyauto_functional.Main() | 73 pyauto_functional.Main() |
| OLD | NEW |