@@ -408,7 +408,7 @@ class WPTRunner { |
408 | 408 | this.resource = new ResourceLoader(path); |
409 | 409 |
|
410 | 410 | this.flags = []; |
411 | | - this.dummyGlobalThisScript = null; |
| 411 | + this.globalThisInitScripts = []; |
412 | 412 | this.initScript = null; |
413 | 413 |
|
414 | 414 | this.status = new StatusLoader(path); |
@@ -463,17 +463,17 @@ class WPTRunner { |
463 | 463 | initScript = `${initScript}\n\n//===\nglobalThis.location.search = "${locationSearchString}";`; |
464 | 464 | } |
465 | 465 |
|
466 | | - if (initScript === null && this.dummyGlobalThisScript === null) { |
467 | | - return null; |
| 466 | + if (this.globalThisInitScripts.length === null) { |
| 467 | + return initScript; |
468 | 468 | } |
469 | 469 |
|
| 470 | + const globalThisInitScript = this.globalThisInitScripts.join('\n\n//===\n'); |
| 471 | + |
470 | 472 | if (initScript === null) { |
471 | | - return this.dummyGlobalThisScript; |
472 | | - } else if (this.dummyGlobalThisScript === null) { |
473 | | - return initScript; |
| 473 | + return globalThisInitScript; |
474 | 474 | } |
475 | 475 |
|
476 | | - return `${this.dummyGlobalThisScript}\n\n//===\n${initScript}`; |
| 476 | + return `${globalThisInitScript}\n\n//===\n${initScript}`; |
477 | 477 | } |
478 | 478 |
|
479 | 479 | /** |
@@ -484,8 +484,9 @@ class WPTRunner { |
484 | 484 | pretendGlobalThisAs(name) { |
485 | 485 | switch (name) { |
486 | 486 | 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;`); |
489 | 490 | break; |
490 | 491 | } |
491 | 492 |
|
|