Skip to content

[BUG] Native C++ Callback does not work when running Electron App with Node Add-on using Playwright #12569

@anvosoughi

Description

@anvosoughi

Context:

  • Playwright Version: 1.19.2
  • Operating System: Windows 10
  • Node.js version: 16.14.0
  • Electron: 17.1.0
  • Node Add-on: build with Electron "17.1.0" and "node-addon-api": "^4.3.0"

Bug Repository

https://github.com/anvosoughi/playwright-electron-node-addon-sample

Electron Code:

https://github.com/anvosoughi/playwright-electron-node-addon-sample/blob/main/electron/main.js

Playwright Code

https://github.com/anvosoughi/playwright-electron-node-addon-sample/blob/main/e2e/specs/home.spec.ts

Describe the bug

I have a simple Electron sample app, which uses the 'node-addon-api' to make a call from JavaScript(electron app) to C++ add-on, and receive a callback from C++ add-on to the JavaScript(electron app).

When the app is launched, the triggerCallback function is automatically executed, which triggers C++ add-on to make one call to the app every second using a callback.

There is a console output of "triggerCallback fired" when the function is executed. And "callback result: XX" is printed to console every second thereafter.

This works well when launching the app without Playwright
image

But when we use Playwright to launch the app, the function is executed as expected, but the call back does not fire.
image

Note:

You can also trigger the callback manually using the button with text "Trigger Callback"

This app is for Windows OS only

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions