Skip to content

Commit f0e8ff9

Browse files
joyeecheungtargos
authored andcommitted
test: use an array for WPT gloablThis initialization scripts
So that we can add multiple initialization scripts in the test runner. Refs: #44483 PR-URL: #46425 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent a0d4b69 commit f0e8ff9

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/common/wpt.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class WPTRunner {
408408
this.resource = new ResourceLoader(path);
409409

410410
this.flags = [];
411-
this.dummyGlobalThisScript = null;
411+
this.globalThisInitScripts = [];
412412
this.initScript = null;
413413

414414
this.status = new StatusLoader(path);
@@ -463,17 +463,17 @@ class WPTRunner {
463463
initScript = `${initScript}\n\n//===\nglobalThis.location.search = "${locationSearchString}";`;
464464
}
465465

466-
if (initScript === null && this.dummyGlobalThisScript === null) {
467-
return null;
466+
if (this.globalThisInitScripts.length === null) {
467+
return initScript;
468468
}
469469

470+
const globalThisInitScript = this.globalThisInitScripts.join('\n\n//===\n');
471+
470472
if (initScript === null) {
471-
return this.dummyGlobalThisScript;
472-
} else if (this.dummyGlobalThisScript === null) {
473-
return initScript;
473+
return globalThisInitScript;
474474
}
475475

476-
return `${this.dummyGlobalThisScript}\n\n//===\n${initScript}`;
476+
return `${globalThisInitScript}\n\n//===\n${initScript}`;
477477
}
478478

479479
/**
@@ -484,8 +484,9 @@ class WPTRunner {
484484
pretendGlobalThisAs(name) {
485485
switch (name) {
486486
case 'Window': {
487-
this.dummyGlobalThisScript =
488-
'global.Window = Object.getPrototypeOf(globalThis).constructor;';
487+
this.globalThisInitScripts.push(
488+
`global.Window = Object.getPrototypeOf(globalThis).constructor;
489+
self.GLOBAL.isWorker = () => false;`);
489490
break;
490491
}
491492

0 commit comments

Comments
 (0)