Update default settings for browser versions such that the given feature is available everywhere.
(feature, reason, override=False)
| 222 | |
| 223 | |
| 224 | def enable_feature(feature, reason, override=False): |
| 225 | """Update default settings for browser versions such that the given feature is available everywhere.""" |
| 226 | if override: |
| 227 | enable_override_features.add(feature) |
| 228 | for name, min_version in min_browser_versions[feature].items(): |
| 229 | name = f'MIN_{name.upper()}_VERSION' |
| 230 | if settings[name] < min_version: |
| 231 | if name in user_settings: |
| 232 | # If the user explicitly chose an older version we issue a warning. |
| 233 | if name == 'MIN_SAFARI_VERSION' and reason == 'pthreads': |
| 234 | # But as a special case, don't warn when forcing on bulk memory on Safari. |
| 235 | # This is because Safari implemented part of bulk memory along with threads in 14.1, |
| 236 | # but not all of it. So bulk-mem is listed as supported in 15.0. So we want to |
| 237 | # continue enabling bulk memory via pthreads without a warning in 14.1, but without |
| 238 | # enabling other features requiring 15.0. |
| 239 | continue |
| 240 | diagnostics.warning( |
| 241 | 'compatibility', |
| 242 | f'{name}={user_settings[name]} is not compatible with {reason} ' |
| 243 | f'({name}={min_version} or above required)') |
| 244 | else: |
| 245 | # If no conflict, bump the minimum version to accommodate the feature. |
| 246 | logger.debug(f'Enabling {name}={min_version} to accommodate {reason}') |
| 247 | setattr(settings, name, min_version) |
| 248 | |
| 249 | |
| 250 | def disable_feature(feature): |
no test coverage detected