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

Method pretendGlobalThisAs

test/common/wpt.js:651–666  ·  view source on GitHub ↗

* Pretend the runner is run in `name`'s environment (globalThis). * @param {'Window'} name * @see https://github.com/nodejs/node/blob/24673ace8ae196bd1c6d4676507d6e8c94cf0b90/test/fixtures/wpt/resources/idlharness.js#L654-L671

(name)

Source from the content-addressed store, hash-verified

649 * @see {@link https://github.com/nodejs/node/blob/24673ace8ae196bd1c6d4676507d6e8c94cf0b90/test/fixtures/wpt/resources/idlharness.js#L654-L671}
650 */
651 pretendGlobalThisAs(name) {
652 switch (name) {
653 case 'Window': {
654 this.globalThisInitScripts.push('globalThis.Window = Object.getPrototypeOf(globalThis).constructor;');
655 break;
656 }
657
658 // TODO(XadillaX): implement `ServiceWorkerGlobalScope`,
659 // `DedicateWorkerGlobalScope`, etc.
660 //
661 // e.g. `ServiceWorkerGlobalScope` should implement dummy
662 // `addEventListener` and so on.
663
664 default: throw new Error(`Invalid globalThis type ${name}.`);
665 }
666 }
667
668 // TODO(joyeecheung): work with the upstream to port more tests in .html
669 // to .js.

Callers 11

test-url.jsFile · 0.80
test-urlpattern.jsFile · 0.80
test-encoding.jsFile · 0.80
test-web-locks.jsFile · 0.80
test-webcrypto.jsFile · 0.80
test-streams.jsFile · 0.80
test-hr-time.jsFile · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected