2023-04-03 00:04:57 +08:00
|
|
|
// Flags: --experimental-shadow-realm --max-old-space-size=20
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verifying ShadowRealm instances can be correctly garbage collected.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const common = require('../common');
|
2023-11-14 23:42:36 +01:00
|
|
|
const { runAndBreathe } = require('../common/gc');
|
2023-04-03 00:04:57 +08:00
|
|
|
const assert = require('assert');
|
|
|
|
|
const { isMainThread, Worker } = require('worker_threads');
|
|
|
|
|
|
2023-11-14 23:42:36 +01:00
|
|
|
runAndBreathe(() => {
|
2023-04-03 00:04:57 +08:00
|
|
|
const realm = new ShadowRealm();
|
|
|
|
|
realm.evaluate('new TextEncoder(); 1;');
|
2023-11-14 23:42:36 +01:00
|
|
|
}, 100).then(common.mustCall());
|
2023-04-03 00:04:57 +08:00
|
|
|
|
2023-11-14 23:42:36 +01:00
|
|
|
// Test it in worker too.
|
2023-04-03 00:04:57 +08:00
|
|
|
if (isMainThread) {
|
|
|
|
|
const worker = new Worker(__filename);
|
|
|
|
|
worker.on('exit', common.mustCall((code) => {
|
|
|
|
|
assert.strictEqual(code, 0);
|
|
|
|
|
}));
|
|
|
|
|
}
|