summaryrefslogtreecommitdiff
path: root/test/parallel/test-shadow-realm-globals.js
blob: 8e0107597985ad1d29971b2fc9425a71692bb570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Flags: --experimental-shadow-realm
'use strict';

require('../common');
const { intrinsics, webIdlExposedWildcard } = require('../common/globals');
const assert = require('assert');

// Validates APIs exposed on the ShadowRealm globalThis.
const shadowRealm = new ShadowRealm();
const itemsStr = shadowRealm.evaluate(`
(() => {
  return Object.getOwnPropertyNames(globalThis).join(',');
})();
`);
const items = itemsStr.split(',');
const leaks = [];
for (const item of items) {
  if (intrinsics.has(item)) {
    continue;
  }
  if (webIdlExposedWildcard.has(item)) {
    continue;
  }
  leaks.push(item);
}

assert.deepStrictEqual(leaks, []);