MCPcopy Create free account
hub / github.com/nodejs/node / createRealms

Function createRealms

test/fixtures/wpt/encoding/streams/realms.window.js:36–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36async function createRealms() {
37 // All realms are visible on the global object so they can access each other.
38
39 // The realm that the constructor function comes from.
40 window.constructorRealm = await createRealm();
41
42 // The realm in which the constructor object is called.
43 window.constructedRealm = await createRealm();
44
45 // The realm in which reading happens.
46 window.readRealm = await createRealm();
47
48 // The realm in which writing happens.
49 window.writeRealm = await createRealm();
50
51 // The realm that provides the definitions of Readable and Writable methods.
52 window.methodRealm = await createRealm();
53
54 await evalInRealmAndWait(methodRealm, `
55 window.ReadableStreamDefaultReader =
56 new ReadableStream().getReader().constructor;
57 window.WritableStreamDefaultWriter =
58 new WritableStream().getWriter().constructor;
59`);
60 window.readMethod = methodRealm.ReadableStreamDefaultReader.prototype.read;
61 window.writeMethod = methodRealm.WritableStreamDefaultWriter.prototype.write;
62}
63
64// In order for values to be visible between realms, they need to be
65// global. To prevent interference between tests, variable names are generated

Callers 1

realms.window.jsFile · 0.70

Calls 2

evalInRealmAndWaitFunction · 0.85
createRealmFunction · 0.70

Tested by

no test coverage detected