MCPcopy Index your code
hub / github.com/nodejs/node / fullInitScript

Method fullInitScript

test/common/wpt.js:622–644  ·  view source on GitHub ↗

* @param {WPTTestSpec} spec * @returns {string}

(spec)

Source from the content-addressed store, hash-verified

620 * @returns {string}
621 */
622 fullInitScript(spec) {
623 const url = new URL(`/${spec.getRelativePath().replace(/\.js$/, '.html')}${spec.variant}`, 'http://wpt');
624 const title = spec.getMeta().title;
625 let { initScript } = this;
626
627 initScript = `${initScript}\n\n//===\nglobalThis.location = new URL("${url.href}");`;
628
629 if (title) {
630 initScript = `${initScript}\n\n//===\nglobalThis.META_TITLE = "${title}";`;
631 }
632
633 if (this.globalThisInitScripts.length === null) {
634 return initScript;
635 }
636
637 const globalThisInitScript = this.globalThisInitScripts.join('\n\n//===\n');
638
639 if (initScript === null) {
640 return globalThisInitScript;
641 }
642
643 return `${globalThisInitScript}\n\n//===\n${initScript}`;
644 }
645
646 /**
647 * Pretend the runner is run in `name`'s environment (globalThis).

Callers 1

runJsTestsMethod · 0.95

Calls 3

getRelativePathMethod · 0.80
getMetaMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected