MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / get_firefox_version

Function get_firefox_version

test/browser_common.py:178–205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176
177@memoize
178def get_firefox_version():
179 if not is_firefox():
180 return UNSUPPORTED
181 exe_path = shutil.which(shlex.split(EMTEST_BROWSER)[0])
182 ini_path = os.path.join(os.path.dirname(exe_path), '../Resources/platform.ini' if MACOS else 'platform.ini')
183 # On Linux, Firefox system installation uses a specific directory structure,
184 # where platform.ini is not located in same directory as the browser executable.
185 if LINUX and exe_path.startswith('/usr/bin/'):
186 def find_system_firefox_platform_ini():
187 for path in ['/usr/lib/firefox-esr/', '/usr/lib/firefox/']:
188 ini = os.path.join(path, 'platform.ini')
189 if os.path.isfile(ini):
190 return ini
191
192 ini_path = find_system_firefox_platform_ini()
193 if not ini_path:
194 logger.warning(f'Firefox browser detected in {EMTEST_BROWSER}, but could not find Firefox platform.ini to detect Firefox version. Assuming OLDEST_SUPPORTED_FIREFOX={OLDEST_SUPPORTED_FIREFOX}')
195 return OLDEST_SUPPORTED_FIREFOX
196
197 # Extract the first numeric part before any dot (e.g. "Milestone=102.15.1" → 102)
198 m = re.search(r"^Milestone=(.*)$", read_file(ini_path), re.MULTILINE)
199 milestone = m.group(1).strip()
200 version = int(re.match(r"(\d+)", milestone).group(1))
201 # On Nightly and Beta, e.g. 145.0a1, pretend it to still mean version 144,
202 # since it is a pre-release version
203 if any(c in milestone for c in ('a', 'b')):
204 version -= 1
205 return version
206
207
208def browser_should_skip_feature(skip_env_var, feature):

Callers 1

Calls 7

is_firefoxFunction · 0.85
splitMethod · 0.80
warningMethod · 0.80
read_fileFunction · 0.50
joinMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected