mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-06 16:17:56 +02:00
test(stealth): comprehensive unit + e2e tests, fix platform mismatch
Tests (52 total, 0 failures): Unit tests (33): - Module exports validation (stealthArgs shape, applyStealthPatches type) - Launch args content (AutomationControlled, no-first-run, no forbidden flags) - Init script source analysis (all 10 patch vectors verified present) - applyStealthPatches API (mock context, GPU args, serialization, idempotency) - Adversarial edge cases (array spread safety, extension compat, GPU plausibility) - Import integration (browser-manager.ts correctly imports and calls both paths) - Old inline patches removal verification E2E tests (19): - Real Chromium launch with stealth patches applied - navigator.webdriver value AND property existence - WebGL1 + WebGL2 renderer spoofing - PluginArray instanceof + shape verification - Complete chrome object (app, runtime, loadTimes, csi) - Languages, permissions, CDP artifacts, Playwright globals - Platform/UA consistency - Patches survive page navigation Bug fix: navigator.platform now spoofed to 'MacIntel' when UA claims Macintosh. Previously reported 'Linux x86_64' in containers, which contradicts the Mac user agent and is a detectable fingerprint mismatch. Caught by the e2e test.
This commit is contained in:
+11
-1
@@ -188,7 +188,7 @@ export async function applyStealthPatches(
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// 5. LANGUAGES
|
||||
// 5. LANGUAGES + PLATFORM
|
||||
// ========================================
|
||||
Object.defineProperty(navigator, 'languages', {
|
||||
get: () => ['en-US', 'en'],
|
||||
@@ -196,6 +196,16 @@ export async function applyStealthPatches(
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
// Platform must match the user agent. If UA says Mac, platform must be MacIntel.
|
||||
// navigator.platform is 'Linux x86_64' in containers which contradicts a Mac UA.
|
||||
if (navigator.userAgent.includes('Macintosh')) {
|
||||
Object.defineProperty(navigator, 'platform', {
|
||||
get: () => 'MacIntel',
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// 6. CDP ARTIFACT CLEANUP
|
||||
// ========================================
|
||||
|
||||
Reference in New Issue
Block a user