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

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/check_injected_script_source.py

Issue 2235703003: [DevTools] Remove Map usage from InjectedScriptSource.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2014 Google Inc. All rights reserved. 2 # Copyright (c) 2014 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 "concat", "every", "filter", "forEach", "indexOf", "join", "lastIndexOf" , "map", "pop", 42 "concat", "every", "filter", "forEach", "indexOf", "join", "lastIndexOf" , "map", "pop",
43 "push", "reduce", "reduceRight", "reverse", "shift", "slice", "some", "s ort", "splice", "toLocaleString", "toString", "unshift", 43 "push", "reduce", "reduceRight", "reverse", "shift", "slice", "some", "s ort", "splice", "toLocaleString", "toString", "unshift",
44 # Function.prototype.* 44 # Function.prototype.*
45 "apply", "bind", "call", "isGenerator", "toSource", 45 "apply", "bind", "call", "isGenerator", "toSource",
46 # Object.prototype.* 46 # Object.prototype.*
47 "toString", 47 "toString",
48 ]) 48 ])
49 49
50 global_functions = "|".join([ 50 global_functions = "|".join([
51 "eval", "uneval", "isFinite", "isNaN", "parseFloat", "parseInt", "decode URI", "decodeURIComponent", 51 "eval", "uneval", "isFinite", "isNaN", "parseFloat", "parseInt", "decode URI", "decodeURIComponent",
52 "encodeURI", "encodeURIComponent", "escape", "unescape", 52 "encodeURI", "encodeURIComponent", "escape", "unescape", "Map", "Set"
53 ]) 53 ])
54 54
55 # Black list: 55 # Black list:
56 # - instanceof, since e.g. "obj instanceof Error" may throw if Error is over ridden and is not a function 56 # - instanceof, since e.g. "obj instanceof Error" may throw if Error is over ridden and is not a function
57 # - Object.prototype.toString() 57 # - Object.prototype.toString()
58 # - Array.prototype.* 58 # - Array.prototype.*
59 # - Function.prototype.* 59 # - Function.prototype.*
60 # - Math.* 60 # - Math.*
61 # - Global functions 61 # - Global functions
62 black_list_call_regex = re.compile(r"\sinstanceof\s+\w*|\bMath\.\w+\(|(?<!In jectedScriptHost)\.(" + proto_functions + r")\(|[^\.]\b(" + global_functions + r ")\(") 62 black_list_call_regex = re.compile(r"\sinstanceof\s+\w*|\bMath\.\w+\(|(?<!In jectedScriptHost)\.(" + proto_functions + r")\(|[^\.]\b(" + global_functions + r ")\(")
63 63
64 errors_found = False 64 errors_found = False
65 for i, line in enumerate(lines): 65 for i, line in enumerate(lines):
66 if line.find("suppressBlacklist"): 66 if line.find("suppressBlacklist") != -1:
67 continue 67 continue
68 for match in re.finditer(black_list_call_regex, line): 68 for match in re.finditer(black_list_call_regex, line):
69 errors_found = True 69 errors_found = True
70 print "ERROR: Black listed expression in %s at line %02d column %02d : %s" % (os.path.basename(fileName), i + 1, match.start(), match.group(0)) 70 print "ERROR: Black listed expression in %s at line %02d column %02d : %s" % (os.path.basename(fileName), i + 1, match.start(), match.group(0))
71 71
72 if not errors_found: 72 if not errors_found:
73 print "OK" 73 print "OK"
74 74
75 75
76 def main(argv): 76 def main(argv):
77 if len(argv) < 2: 77 if len(argv) < 2:
78 print('ERROR: Usage: %s path/to/InjectedScriptSource.js' % argv[0]) 78 print('ERROR: Usage: %s path/to/InjectedScriptSource.js' % argv[0])
79 return 1 79 return 1
80 80
81 validate_injected_script(argv[1]) 81 validate_injected_script(argv[1])
82 82
83 if __name__ == '__main__': 83 if __name__ == '__main__':
84 sys.exit(main(sys.argv)) 84 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698