OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Embeds standalone JavaScript snippets in C++ code. | 6 """Embeds standalone JavaScript snippets in C++ code. |
7 | 7 |
8 Each argument to the script must be a file containing an associated JavaScript | 8 Each argument to the script must be a file containing an associated JavaScript |
9 function (e.g., evaluate_script.js should contain an evaluateScript function). | 9 function (e.g., evaluate_script.js should contain an evaluateScript function). |
10 This is called the exported function of the script. The entire script will be | 10 This is called the exported function of the script. The entire script will be |
(...skipping 19 matching lines...) Expand all Loading... |
30 for js_file in args: | 30 for js_file in args: |
31 base_name = os.path.basename(js_file)[:-3].title().replace('_', '') | 31 base_name = os.path.basename(js_file)[:-3].title().replace('_', '') |
32 func_name = base_name[0].lower() + base_name[1:] | 32 func_name = base_name[0].lower() + base_name[1:] |
33 script_name = 'k%sScript' % base_name | 33 script_name = 'k%sScript' % base_name |
34 with open(js_file, 'r') as f: | 34 with open(js_file, 'r') as f: |
35 contents = f.read() | 35 contents = f.read() |
36 script = 'function() { %s; return %s.apply(null, arguments) }' % ( | 36 script = 'function() { %s; return %s.apply(null, arguments) }' % ( |
37 contents, func_name) | 37 contents, func_name) |
38 global_string_map[script_name] = script | 38 global_string_map[script_name] = script |
39 | 39 |
40 cpp_source.WriteSource('js', 'chrome/test/chromedriver', | 40 cpp_source.WriteSource('js', 'chrome/test/chromedriver/chrome', |
41 options.directory, global_string_map) | 41 options.directory, global_string_map) |
42 | 42 |
43 | 43 |
44 if __name__ == '__main__': | 44 if __name__ == '__main__': |
45 sys.exit(main()) | 45 sys.exit(main()) |
OLD | NEW |