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

[REGRESSION] 1.28 breaks Electron detecting app name, version, paths from package.json #19648

Closed
andersk opened this issue Dec 22, 2022 · 1 comment · Fixed by #19650
Closed

Comments

@andersk
Copy link
Contributor

andersk commented Dec 22, 2022

Context:

  • Playwright Version: 1.28.0, 1.29.1
  • Operating System: Linux
  • Node.js version: 18.12.1
  • Browser: Chromium

Code Snippet

package.json

{
  "name": "my-test-app",
  "productName": "MyTestApp",
  "version": "1.2.3",
  "dependencies": {
    "electron": "^22.0.0",
    "playwright-core": "^1.28.0"
  }
}

index.js

const fs = require("node:fs");
const { app, BrowserWindow } = require("electron");

fs.writeFileSync(
  "/tmp/log",
  `\
- app.name = ${app.name}
- app.getName() = ${app.getName()}
- app.getVersion() = ${app.getVersion()}
- app.getPath("userData") = ${app.getPath("userData")}
- app.getPath("sessionData") = ${app.getPath("sessionData")}
- app.getPath("logs") = ${app.getPath("logs")}
- app.getPath("crashDumps") = ${app.getPath("crashDumps")}
`
);
app.whenReady().then(async () => {
  await new BrowserWindow().loadURL("about:blank");
  app.quit();
});

test.js

const { _electron } = require("playwright-core");

(async () => {
  const app = await _electron.launch({ args: ["."] });
  app.close();
})();

Describe the bug

When an Electron application is run normally (npx electron .), or through Playwright ≤ 1.27.1, Electron correctly detects the application name, version, and various paths based on the name, productName, and version listed in package.json.

$ npx electron .
$ cat /tmp/log
- app.name = MyTestApp
- app.getName() = MyTestApp
- app.getVersion() = 1.2.3
- app.getPath("userData") = /home/anders/.config/MyTestApp
- app.getPath("sessionData") = /home/anders/.config/MyTestApp
- app.getPath("logs") = /home/anders/.config/MyTestApp/logs
- app.getPath("crashDumps") = /home/anders/.config/MyTestApp/Crashpad

However, when it’s run through Playwright ≥ 1.28.0, this detection is broken, and Electron substitutes generic defaults.

$ node test.js
$ cat /tmp/log
- app.name = Electron
- app.getName() = Electron
- app.getVersion() = 22.0.0
- app.getPath("userData") = /home/anders/.config/Electron
- app.getPath("sessionData") = /home/anders/.config/Electron
- app.getPath("logs") = /home/anders/.config/Electron/logs
- app.getPath("crashDumps") = /home/anders/.config/Electron/Crashpad
@andersk
Copy link
Contributor Author

andersk commented Dec 22, 2022

This was also first broken by #18804 (cc @pavelfeldman).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants