Skip to content

4 fork work fix browserautherror crypto nonexistent for firefox upstream issue 8391#8482

Open
Christopher-C-Robinson wants to merge 6 commits intoDevExpress:masterfrom
Christopher-C-Robinson:4-fork-work-fix-browserautherror-crypto_nonexistent-for-firefox-upstream-issue-8391
Open

4 fork work fix browserautherror crypto nonexistent for firefox upstream issue 8391#8482
Christopher-C-Robinson wants to merge 6 commits intoDevExpress:masterfrom
Christopher-C-Robinson:4-fork-work-fix-browserautherror-crypto_nonexistent-for-firefox-upstream-issue-8391

Conversation

@Christopher-C-Robinson
Copy link

Purpose

Fix BrowserAuthError: crypto_nonexistent behavior reported in #8391 for Firefox runs in proxy mode (--disable-native-automation), and add regression coverage.

Approach

References

Validation

  • gulp test-server (local): 809 passing, 1 pending, 3 failing
  • Failures are local-environment related and tied to macOS Screen Recording API access:
    • Runner .src() -> Should accept source files in different forms
    • Runner Regression -> Should not have unhandled rejections in runner (GH-825)
    • Runner after all hook ...
    • error: UnableToAccessScreenRecordingAPIError: The find-window process cannot access the Screen Recording API
  • Focused runner check passes:
    • npx mocha test/server/runner-test.js --timeout 120000 --grep "permission|retry|_checkRequiredPermissions"
    • result: 3 passing

Pre-Merge TODO

  • Write tests for your proposed changes
  • Make sure that existing tests do not fail (blocked locally by macOS Screen Recording permission/TCC behavior)

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 19, 2026
Christopher Robinson added 3 commits February 19, 2026 13:24
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.
@Christopher-C-Robinson Christopher-C-Robinson force-pushed the 4-fork-work-fix-browserautherror-crypto_nonexistent-for-firefox-upstream-issue-8391 branch from ee014a5 to 188a229 Compare February 19, 2026 19:24
@Christopher-C-Robinson Christopher-C-Robinson marked this pull request as ready for review February 19, 2026 19:29
Copilot AI review requested due to automatic review settings February 19, 2026 19:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 localhost for 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.

Comment on lines +357 to 362
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);
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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).

Copilot uses AI. Check for mistakes.
@@ -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' });
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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 });

Copilot uses AI. Check for mistakes.
@aleks-pro aleks-pro added the STATE: PR Review Pending A note that this PR will be reviewed. label Feb 23, 2026
@github-actions
Copy link

Thank you for your contribution to TestCafe. When a member of the TestCafe team becomes available, they will review this PR.

@github-actions github-actions bot removed STATE: Need response An issue that requires a response or attention from the team. STATE: PR Review Pending A note that this PR will be reviewed. labels Feb 23, 2026
@Bayheck Bayheck self-assigned this Feb 26, 2026
@Bayheck
Copy link
Collaborator

Bayheck commented Feb 26, 2026

Hello,
I managed to reproduce the minimal example issue you created earlier and verified it with your proposed fix.
The fix looks correct to me.

However, the gh-8391 regression test appears to pass even without the fix applied.
Additionally, the "Native automation is disabled/all browsers are local/hostname is unset" server test is failing on my machine. Is it passing on yours?
Could you please take a look?

P.S. I’ve also triggered test workflows, so we’ll see how they run.

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 26, 2026
@Bayheck Bayheck removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 26, 2026
@Christopher-C-Robinson
Copy link
Author

Hello, I managed to reproduce the minimal example issue you created earlier and verified it with your proposed fix. The fix looks correct to me.

However, the gh-8391 regression test appears to pass even without the fix applied. Additionally, the "Native automation is disabled/all browsers are local/hostname is unset" server test is failing on my machine. Is it passing on yours? Could you please take a look?

P.S. I’ve also triggered test workflows, so we’ll see how they run.

Thanks for the review. I dug into all points.

I reproduced and investigated them locally:

  1. gh-8391 regression test validity
    I A/B tested with testcafe-hammerhead:
  • 31.7.5: Firefox proxy-mode regression test fails (browser disconnect during init)
  • 31.7.7: same test passes

So the regression test is meaningful for the hammerhead bump/fix path.

  1. Failing server test (Native automation is disabled/all browsers are local/hostname is unset)
    I reproduced this and found the root cause: on Windows, cleanup in configuration-test could leave stale .testcaferc* files due path format, so hostname leaked from prior test state.
    I fixed cleanup to reliably remove default config files in that suite.

  2. Local Firefox workflow failures (iframe-switching)
    I reproduced both failures:

  • cross-domain iframe redirect assertion
  • unavailable iframe action assertion flake

I stabilized those tests by:

  • adding short waits at redirect/removal race points
  • replacing fragile redirected-page counter checks with direct DOM-visible click assertions

I reran the previously failing Firefox cases multiple times locally; they are now stable.

Commits:

  • 4bf975ec test: stabilize configuration default-path cleanup on Windows
  • 8cce2461 test: stabilize Firefox iframe-switching redirect/unavailable cases

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 26, 2026
@Christopher-C-Robinson
Copy link
Author

I’m going to attempt a testing matrix of with both hammerhead versions and both with and without my changes to see if the hammerhead upgrade just fixes the issue and this PR may not be needed..

@Christopher-C-Robinson
Copy link
Author

Thanks for the review notes. I dug into this and re-ran the validation on February 26, 2026 with a corrected baseline comparison:

  • upstream/master (cd8b2c6b)
  • PR head (8cce2461)
  • testcafe-hammerhead 31.7.5 and 31.7.7
  • External repro flow: C:\Code\FP\Test-Automation -> FormsPro/test-sites (Firefox) against https://formspro.omnibyte.com/automation/nightly

Matrix results:

Baseline Hammerhead Result
master (cd8b2c6b) 31.7.5 pass
master (cd8b2c6b) 31.7.7 pass
PR head (8cce2461) 31.7.5 pass
PR head (8cce2461) 31.7.7 pass

No BrowserAuthError / crypto_nonexistent appeared in any of these runs.

So for this repro path, I can’t currently show:

  1. a failure on master, or
  2. a behavioral difference introduced by this PR.

Also confirming your other point: the gh-8391 regression test can pass without the fix, so it does not currently isolate the issue strongly enough.

@testcafe-need-response-bot testcafe-need-response-bot bot removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 26, 2026
@Christopher-C-Robinson Christopher-C-Robinson deleted the 4-fork-work-fix-browserautherror-crypto_nonexistent-for-firefox-upstream-issue-8391 branch February 26, 2026 21:50
@Christopher-C-Robinson Christopher-C-Robinson restored the 4-fork-work-fix-browserautherror-crypto_nonexistent-for-firefox-upstream-issue-8391 branch February 27, 2026 16:31
@Christopher-C-Robinson
Copy link
Author

Christopher-C-Robinson commented Feb 27, 2026

Reopening with a minimal, public URL repro that does not rely on any private test suite.

Verified: February 27, 2026


Environment


Minimal Repro (crypto-probe.js)

import { ClientFunction } from 'testcafe';

fixturecrypto-check
.pagehttps://formspro.omnibyte.com/automation/nightly;

const probe = ClientFunction(() => ({
isSecureContext: window.isSecureContext,
hasCrypto: typeof window.crypto !== 'undefined',
hasSubtle: !!(window.crypto && window.crypto.subtle),
}));

test('webcrypto availability', async t => {
const v = await probe();
console.log('CRYPTO_PROBE:' + JSON.stringify(v));
await t.expect(v.hasCrypto).ok();
});


Commands and Results

Default hostname

npx testcafe firefox crypto-probe.js

Output includes:

CRYPTO_PROBE:{"isSecureContext":false,"hasCrypto":true,"hasSubtle":false}

Forced localhost

npx testcafe firefox crypto-probe.js --hostname localhost

Output includes:

CRYPTO_PROBE:{"isSecureContext":true,"hasCrypto":true,"hasSubtle":true}

Hammerhead Versions Tested

Version Default Host (hasSubtle) --hostname localhost (hasSubtle)
31.7.5 false true
31.7.7 false true

Behavior is identical across both versions.


Relation to Reported Issue

In failing runs, proxied scripts are served from non-localhost hosts (e.g., http://192.168.x.x:<port>/...). In this context, the application throws:

BrowserAuthError: crypto_nonexistent: The crypto object or function is not available.

Forcing --hostname localhost restores a secure context and enables WebCrypto (window.crypto.subtle).


Conclusion

  • Issue remains reproducible.

  • Behavior is hostname/proxy-context dependent in Firefox.

  • Updating Hammerhead alone does not resolve it in this repro.

  • Current workaround: run with --hostname localhost.

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 27, 2026
@Christopher-C-Robinson Christopher-C-Robinson marked this pull request as draft February 27, 2026 18:05
@Christopher-C-Robinson
Copy link
Author

Marked as draft, doing more digging.

@Christopher-C-Robinson
Copy link
Author

Rechecked this end-to-end (Feb 27, 2026) using a real Firefox run against https://formspro.omnibyte.com/automation/nightly and without the --hostname localhost workaround.

Findings:

  • testcafe master (v3.7.4, hammerhead 31.7.7): fails (Test timeout 120000ms).
  • this branch (with localhost-for-local-browsers proxy-mode fix): passes in ~6s.
  • So hammerhead bump alone does not resolve this case; the hostname calculation fix is required.

I also updated gh-8391 regression coverage so it now validates the actual failure mode:

  • hostname intentionally unset
  • native automation disabled (proxy mode)
  • asserts window.isSecureContext and window.crypto.subtle are available

This new regression fails on unpatched code and passes with the fix.

I also reran the server test:
“Native automation is disabled/all browsers are local/hostname is unset”
and it passes on my machine.

@Christopher-C-Robinson Christopher-C-Robinson marked this pull request as ready for review February 27, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

STATE: Need response An issue that requires a response or attention from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants