()
| 668 | // TODO(joyeecheung): work with the upstream to port more tests in .html |
| 669 | // to .js. |
| 670 | async runJsTests() { |
| 671 | const queue = this.buildQueue(); |
| 672 | |
| 673 | const run = limit(this.concurrency); |
| 674 | |
| 675 | for (const spec of queue) { |
| 676 | const content = spec.getContent(); |
| 677 | const meta = spec.getMeta(content); |
| 678 | |
| 679 | const absolutePath = spec.getAbsolutePath(); |
| 680 | const relativePath = spec.getRelativePath(); |
| 681 | const harnessPath = fixtures.path('wpt', 'resources', 'testharness.js'); |
| 682 | |
| 683 | // Scripts specified with the `// META: script=` header |
| 684 | const scriptsToRun = meta.script?.map((script) => { |
| 685 | const obj = { |
| 686 | filename: this.resource.toRealFilePath(relativePath, script), |
| 687 | code: this.resource.read(relativePath, script), |
| 688 | }; |
| 689 | this.scriptsModifier?.(obj); |
| 690 | return obj; |
| 691 | }) ?? []; |
| 692 | // The actual test |
| 693 | const obj = { |
| 694 | code: content, |
| 695 | filename: absolutePath, |
| 696 | }; |
| 697 | this.scriptsModifier?.(obj); |
| 698 | scriptsToRun.push(obj); |
| 699 | |
| 700 | run(async () => { |
| 701 | const worker = new Worker(workerPath, { |
| 702 | execArgv: this.flags, |
| 703 | workerData: { |
| 704 | testRelativePath: relativePath, |
| 705 | wptRunner: __filename, |
| 706 | wptPath: this.path, |
| 707 | initScript: this.fullInitScript(spec), |
| 708 | harness: { |
| 709 | code: fs.readFileSync(harnessPath, 'utf8'), |
| 710 | filename: harnessPath, |
| 711 | }, |
| 712 | scriptsToRun, |
| 713 | needsGc: !!meta.script?.find((script) => script === '/common/gc.js'), |
| 714 | skippedTests: spec.skippedTests, |
| 715 | }, |
| 716 | }); |
| 717 | this.inProgress.add(spec); |
| 718 | this.workers.set(spec, worker); |
| 719 | |
| 720 | const reportResult = this.report?.getResult(spec); |
| 721 | worker.on('message', (message) => { |
| 722 | switch (message.type) { |
| 723 | case 'result': |
| 724 | return this.resultCallback(spec, message.result, reportResult); |
| 725 | case 'skip': |
| 726 | return this.skipTest(spec, { name: message.name }, reportResult); |
| 727 | case 'completion': |
no test coverage detected