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

wptrunner: expose gc #1974

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 11 additions & 12 deletions test/wpt/runner/runner/worker.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import buffer from 'node:buffer'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { runInThisContext } from 'node:vm'
import { setFlagsFromString } from 'node:v8'
import { runInNewContext, runInThisContext } from 'node:vm'
import { parentPort, workerData } from 'node:worker_threads'
import { readFileSync } from 'node:fs'
import buffer from 'node:buffer'
import {
setGlobalOrigin,
Response,
Request,
fetch,
FormData,
File,
Headers,
FileReader
fetch, File, FileReader, FormData, Headers, Request, Response, setGlobalOrigin
} from '../../../../index.js'
import { WebSocket } from '../../../../lib/websocket/websocket.js'
import { CloseEvent } from '../../../../lib/websocket/events.js'
import { WebSocket } from '../../../../lib/websocket/websocket.js'

const { initScripts, meta, test, url, path } = workerData

Expand Down Expand Up @@ -142,5 +136,10 @@ for (const script of meta.scripts) {
runInThisContext(script)
}

// A few tests require gc, which can't be passed to a Worker.
// see https://github.com/nodejs/node/issues/16595#issuecomment-340288680
setFlagsFromString('--expose-gc')
globalThis.gc = runInNewContext('gc')

// Finally, run the test.
runInThisContext(test)