Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): remove crypto.randomUUID from the client #6079

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browser/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const HOST = [location.hostname, PORT].filter(Boolean).join(':')
export const SESSION_ID
= PAGE_TYPE === 'orchestrator'
? getBrowserState().contextId
: crypto.randomUUID()
: getBrowserState().testerId
export const ENTRY_URL = `${
location.protocol === 'https:' ? 'wss:' : 'ws:'
}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&sessionId=${SESSION_ID}`
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/client/public/esm-client-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ window.__vitest_browser_runner__ = {
files: { __VITEST_FILES__ },
type: { __VITEST_TYPE__ },
contextId: { __VITEST_CONTEXT_ID__ },
testerId: { __VITEST_TESTER_ID__ },
provider: { __VITEST_PROVIDER__ },
providedContext: { __VITEST_PROVIDED_CONTEXT__ },
};
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface BrowserRunnerState {
wrapModule: <T>(module: () => T) => T
iframeId?: string
contextId: string
testerId: string
runTests?: (tests: string[]) => Promise<void>
createTesters?: (files: string[]) => Promise<void>
cdp?: {
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/node/serverOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function resolveOrchestrator(
__VITEST_FILES__: JSON.stringify(files),
__VITEST_TYPE__: '"orchestrator"',
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
__VITEST_TESTER_ID__: '"none"',
__VITEST_PROVIDED_CONTEXT__: '{}',
})

Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/node/serverTester.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { IncomingMessage, ServerResponse } from 'node:http'
import crypto from 'node:crypto'
import { stringify } from 'flatted'
import { replacer } from './utils'
import type { BrowserServer } from './server'
Expand Down Expand Up @@ -48,6 +49,7 @@ export async function resolveTester(
}),
__VITEST_TYPE__: '"tester"',
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
__VITEST_TESTER_ID__: JSON.stringify(crypto.randomUUID()),
__VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(project.getProvidedContext())),
})

Expand Down
Loading