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

Side by Side Diff: catapult_build/js_checks.py

Issue 3008163002: Revert of "Add tab.IsServiceWorkerReadyOrNotRegist() which tells whether serviceworker ..." (Closed)
Patch Set: Created 3 years, 3 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 | telemetry/telemetry/internal/browser/tab_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import re 5 import re
6 6
7 import eslint 7 import eslint
8 from py_vulcanize import strip_js_comments 8 from py_vulcanize import strip_js_comments
9 9
10 from catapult_build import parse_html 10 from catapult_build import parse_html
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 soup = parse_html.BeautifulSoup(contents) 91 soup = parse_html.BeautifulSoup(contents)
92 script_elements = soup.find_all('script', src=None) 92 script_elements = soup.find_all('script', src=None)
93 return [_FirstStatement(e.get_text()) for e in script_elements] 93 return [_FirstStatement(e.get_text()) for e in script_elements]
94 94
95 95
96 def _FirstStatement(contents): 96 def _FirstStatement(contents):
97 """Extracts the first statement in some JS source code.""" 97 """Extracts the first statement in some JS source code."""
98 stripped_contents = strip_js_comments.StripJSComments(contents).strip() 98 stripped_contents = strip_js_comments.StripJSComments(contents).strip()
99 matches = re.match('^(.*?);', stripped_contents, re.DOTALL) 99 matches = re.match('^(.*?);', stripped_contents, re.DOTALL)
100 if not matches: 100 if not matches:
101 return contents 101 return ''
102 return matches.group(1).strip() 102 return matches.group(1).strip()
103 103
104 104
105 def RunChecks(input_api, output_api, excluded_paths=None): 105 def RunChecks(input_api, output_api, excluded_paths=None):
106 106
107 def ShouldCheck(affected_file): 107 def ShouldCheck(affected_file):
108 if not excluded_paths: 108 if not excluded_paths:
109 return True 109 return True
110 path = affected_file.LocalPath() 110 path = affected_file.LocalPath()
111 return not any(re.match(pattern, path) for pattern in excluded_paths) 111 return not any(re.match(pattern, path) for pattern in excluded_paths)
112 112
113 return JSChecker(input_api, output_api, file_filter=ShouldCheck).RunChecks() 113 return JSChecker(input_api, output_api, file_filter=ShouldCheck).RunChecks()
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/internal/browser/tab_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698