4 fork work fix browserautherror crypto nonexistent for firefox upstream issue 8391#8482
Conversation
When running tests in local browsers with native automation disabled, TestCafe previously attempted to resolve a network-accessible hostname. This process can be slow and may fail in environments with restricted or no network access. This change optimizes this behavior by defaulting the hostname to 'localhost' when all browsers are local and a specific hostname has not been configured. This improves test startup time and enhances reliability for local-only test runs.
ee014a5 to
188a229
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses a Firefox proxy-mode (--disable-native-automation) initialization failure (BrowserAuthError: crypto_nonexistent, #8391) by ensuring TestCafe uses a localhost hostname strategy when all target browsers are local, and adds regression coverage around the scenario.
Changes:
- Update proxy bootstrap flow to detect when all browsers are local and pass that signal into hostname calculation.
- Extend hostname calculation logic to prefer
localhostfor proxy mode when hostname is unset and all browsers are local. - Add/extend server- and functional-level regression tests for GH-8391 and the new hostname strategy.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/runner/bootstrapper.ts |
Computes allBrowsersLocal and feeds it into hostname calculation during proxy setup. |
src/configuration/testcafe-configuration.ts |
Adds allBrowsersLocal support to hostname calculation to select localhost in proxy mode when appropriate. |
test/server/configuration-test.js |
Adds unit coverage for the new hostname calculation branch. |
test/server/bootstrapper-test.js |
Adds a unit test asserting proxy setup uses the localhost hostname strategy for local browsers in proxy mode. |
test/functional/fixtures/regression/gh-8391/* |
Adds a functional regression fixture + page for Firefox proxy-mode initialization. |
package-lock.json |
Lockfile refresh reflecting dependency updates (incl. testcafe-hammerhead). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private async _isAllBrowsersLocal (browserInfo: BrowserInfoSource[]): Promise<boolean> { | ||
| const isLocalPromises = browserInfo.map(browser => browser.provider.isLocalBrowser(void 0, Bootstrapper._getBrowserName(browser))); | ||
| const isLocalBrowsers = await Promise.all(isLocalPromises); | ||
|
|
||
| return isLocalBrowsers.every(result => result); | ||
| } |
There was a problem hiding this comment.
_isAllBrowsersLocal calls browser.provider.isLocalBrowser(void 0, ...) for every BrowserInfoSource. When the entry is a BrowserConnection, an id is available (browser.id) and some providers rely on it to determine locality; passing undefined risks misclassifying remote connections as local, which can incorrectly force hostname to localhost in proxy mode. Pass the connection id for BrowserConnection instances (and keep undefined for plain BrowserInfo).
| @@ -0,0 +1,5 @@ | |||
| describe('[Regression](GH-8391)', function () { | |||
| it('Should not fail Firefox proxy-mode initialization', function () { | |||
| return runTests('testcafe-fixtures/index.js', 'Should run a simple assertion in Firefox proxy mode', { only: 'firefox' }); | |||
There was a problem hiding this comment.
This regression test is intended to verify Firefox behavior specifically in proxy mode (--disable-native-automation), but it doesn’t enforce that mode. Since the functional test harness can run with NATIVE_AUTOMATION=true, this test may execute in native automation and fail to cover the reported scenario. Please skip/guard this test when config.nativeAutomation is true (or explicitly run with disableNativeAutomation: true in this test).
| return runTests('testcafe-fixtures/index.js', 'Should run a simple assertion in Firefox proxy mode', { only: 'firefox' }); | |
| return runTests('testcafe-fixtures/index.js', 'Should run a simple assertion in Firefox proxy mode', { only: 'firefox', disableNativeAutomation: true }); |
Purpose
Fix
BrowserAuthError: crypto_nonexistentbehavior reported in #8391 for Firefox runs in proxy mode (--disable-native-automation), and add regression coverage.Approach
testcafe-hammerheadto include the upstream fix used by TestCafe client/proxy injection.test/functional/fixtures/regression/gh-8391/test.jstest/functional/fixtures/regression/gh-8391/testcafe-fixtures/index.jstest/functional/fixtures/regression/gh-8391/pages/index.htmlReferences
Validation
gulp test-server(local):809 passing,1 pending,3 failingRunner .src() -> Should accept source files in different formsRunner Regression -> Should not have unhandled rejections in runner (GH-825)Runner after all hook ...UnableToAccessScreenRecordingAPIError: The find-window process cannot access the Screen Recording APInpx mocha test/server/runner-test.js --timeout 120000 --grep "permission|retry|_checkRequiredPermissions"3 passingPre-Merge TODO