Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] the coverage and sourceMappingURL don't work if the js added with addScriptTag #29116

Closed
cenfun opened this issue Jan 23, 2024 · 1 comment

Comments

@cenfun
Copy link
Contributor

cenfun commented Jan 23, 2024

System info

  • Playwright Version: [^1.41.0]
  • Operating System: [Windows 10]
  • Browser: [Chromium]

Source code

Example js, path is: .temp/my.js and content:

console.log("my js content with sourceMappingURL comments");
//# sourceMappingURL=my.js.map

Steps

const page = await browser.newPage();
await page.coverage.startJSCoverage();
await page.addScriptTag({
    path: '.temp/my.js'
});
const jsCoverage = await page.coverage.stopJSCoverage();
console.log(jsCoverage); // got nothing 

However, the coverage data exists if enabled reportAnonymousScripts

await page.coverage.startJSCoverage({
    reportAnonymousScripts: true
});

But the source becomes:

console.log("my js content with sourceMappingURL comments");
//# sourceMappingURL=my.js.map//# sourceURL=.temp/my.js

Note, the last line breaks sourceURL and sourceMappingURL

Expected

  • the coverage should work without reportAnonymousScripts
  • the sourceMappingURL should work too
yury-s added a commit to yury-s/playwright that referenced this issue Jan 26, 2024
pavelfeldman pushed a commit that referenced this issue Jan 29, 2024
@cenfun
Copy link
Contributor Author

cenfun commented Jun 22, 2024

It should be fixed.

@cenfun cenfun closed this as completed Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants