()
| 34 | } |
| 35 | |
| 36 | async 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 |
no test coverage detected