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

Side by Side Diff: chrome/test/chromedriver/embed_js_in_cpp.py

Issue 12848005: [chromedriver] Separate stuff of chrome from chromedriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and fix compile error on mac. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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())
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/element_util.cc ('k') | chrome/test/chromedriver/embed_user_data_dir_in_cpp.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698