Skip to content

Commit 59fdfa3

Browse files
KhafraDevmetcoder95
authored andcommitted
wptrunner: expose gc (nodejs#1974)
1 parent b0d1441 commit 59fdfa3

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

test/wpt/runner/runner/worker.mjs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1+
import buffer from 'node:buffer'
2+
import { readFileSync } from 'node:fs'
13
import { join } from 'node:path'
2-
import { runInThisContext } from 'node:vm'
4+
import { setFlagsFromString } from 'node:v8'
5+
import { runInNewContext, runInThisContext } from 'node:vm'
36
import { parentPort, workerData } from 'node:worker_threads'
4-
import { readFileSync } from 'node:fs'
5-
import buffer from 'node:buffer'
67
import {
7-
setGlobalOrigin,
8-
Response,
9-
Request,
10-
fetch,
11-
FormData,
12-
File,
13-
Headers,
14-
FileReader
8+
fetch, File, FileReader, FormData, Headers, Request, Response, setGlobalOrigin
159
} from '../../../../index.js'
16-
import { WebSocket } from '../../../../lib/websocket/websocket.js'
1710
import { CloseEvent } from '../../../../lib/websocket/events.js'
11+
import { WebSocket } from '../../../../lib/websocket/websocket.js'
1812

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

@@ -142,5 +136,10 @@ for (const script of meta.scripts) {
142136
runInThisContext(script)
143137
}
144138

139+
// A few tests require gc, which can't be passed to a Worker.
140+
// see https://github.com/nodejs/node/issues/16595#issuecomment-340288680
141+
setFlagsFromString('--expose-gc')
142+
globalThis.gc = runInNewContext('gc')
143+
145144
// Finally, run the test.
146145
runInThisContext(test)

0 commit comments

Comments
 (0)