OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 '''Uses the closure compiler to check the ChromeVox javascript files. | 7 '''Uses the closure compiler to check the ChromeVox javascript files. |
8 | 8 |
9 With no arguments, checks all ChromeVox scripts. If any arguments are | 9 With no arguments, checks all ChromeVox scripts. If any arguments are |
10 specified, only scripts that include any of the specified files will be | 10 specified, only scripts that include any of the specified files will be |
(...skipping 23 matching lines...) Expand all Loading... |
34 return os.path.relpath(os.path.join(_SCRIPT_DIR, '..', path)) | 34 return os.path.relpath(os.path.join(_SCRIPT_DIR, '..', path)) |
35 | 35 |
36 | 36 |
37 def ChromeRootPath(path='.'): | 37 def ChromeRootPath(path='.'): |
38 '''Converts a path relative to the top-level chromevox directory to a | 38 '''Converts a path relative to the top-level chromevox directory to a |
39 path relative to the current directory. | 39 path relative to the current directory. |
40 ''' | 40 ''' |
41 return os.path.relpath(os.path.join(_CHROME_SOURCE_DIR, path)) | 41 return os.path.relpath(os.path.join(_CHROME_SOURCE_DIR, path)) |
42 | 42 |
43 | 43 |
44 # Name of chrome extensions externs file. | 44 # Automation API externs file. |
45 _CHROME_EXTENSIONS_EXTERNS = ( | 45 _AUTOMATION_EXTERNS = ( |
46 ChromeRootPath('third_party/closure_compiler/externs/chrome_extensions.js')) | 46 ChromeRootPath('third_party/closure_compiler/externs/automation.js')) |
47 | 47 |
48 # MetricsPrivate externs file. | 48 # MetricsPrivate externs file. |
49 _METRICS_PRIVATE_EXTERNS = ( | 49 _METRICS_PRIVATE_EXTERNS = ( |
50 ChromeRootPath('third_party/closure_compiler/externs/metrics_private.js')) | 50 ChromeRootPath('third_party/closure_compiler/externs/metrics_private.js')) |
51 | 51 |
| 52 # Additional chrome extension api externs file. |
| 53 _CHROME_EXTENSIONS_EXTERNS = ( |
| 54 ChromeRootPath('third_party/closure_compiler/externs/chrome_extensions.js')) |
| 55 |
52 | 56 |
53 # Externs common to many ChromeVox scripts. | 57 # Externs common to many ChromeVox scripts. |
54 _COMMON_EXTERNS = [ | 58 _COMMON_EXTERNS = [ |
55 CVoxPath('common/externs.js'), | 59 CVoxPath('common/externs.js'), |
56 CVoxPath('common/chrome_extension_externs.js'), | 60 CVoxPath('common/chrome_extension_externs.js'), |
57 CVoxPath('chromevox/background/externs.js'), | 61 CVoxPath('chromevox/background/externs.js'), |
58 CVoxPath('chromevox/injected/externs.js'), | 62 CVoxPath('chromevox/injected/externs.js'), |
59 CVoxPath('host/chrome/externs.js'), | 63 CVoxPath('host/chrome/externs.js'), |
| 64 _AUTOMATION_EXTERNS, |
60 _CHROME_EXTENSIONS_EXTERNS, | 65 _CHROME_EXTENSIONS_EXTERNS, |
61 _METRICS_PRIVATE_EXTERNS] | 66 _METRICS_PRIVATE_EXTERNS] |
62 | 67 |
63 # List of top-level scripts and externs that we can check. | 68 # List of top-level scripts and externs that we can check. |
64 _TOP_LEVEL_SCRIPTS = [ | 69 _TOP_LEVEL_SCRIPTS = [ |
65 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], _COMMON_EXTERNS], | 70 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], _COMMON_EXTERNS], |
66 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], | 71 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], |
67 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], | 72 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], |
68 [[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS], | 73 [[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS], |
69 [[CVoxPath('cvox2/background/panel_loader.js')], _COMMON_EXTERNS], | 74 [[CVoxPath('cvox2/background/panel_loader.js')], _COMMON_EXTERNS], |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if len(args) > 0: | 142 if len(args) > 0: |
138 changed_paths = (os.path.relpath(p) for p in args) | 143 changed_paths = (os.path.relpath(p) for p in args) |
139 success, output = CheckChromeVox(changed_paths) | 144 success, output = CheckChromeVox(changed_paths) |
140 if len(output) > 0: | 145 if len(output) > 0: |
141 print output | 146 print output |
142 return int(not success) | 147 return int(not success) |
143 | 148 |
144 | 149 |
145 if __name__ == '__main__': | 150 if __name__ == '__main__': |
146 sys.exit(main()) | 151 sys.exit(main()) |
OLD | NEW |