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

[Feature]: Harden playwright against core object manipulation #34328

Open
hakito opened this issue Jan 15, 2025 · 1 comment
Open

[Feature]: Harden playwright against core object manipulation #34328

hakito opened this issue Jan 15, 2025 · 1 comment

Comments

@hakito
Copy link

hakito commented Jan 15, 2025

🚀 Feature Request

We have a situation, where we have to test a System, that replaces the core Map with some other object.

function Map()
{
  // some custom map stuff
}

Map.prototype.customMethod = function ...

Playwright crashes because it also relies on the Map object.

My proposal would be to make copies/references for the core objects and work with them within playwright.

Example

It would be also great to provide the core objects for own javascript calls:

browserContext.ProvideCoreObjectsAs("coreObjects");

And access them in for example in an init script:

myMap = new globalThis.coreObjects.Map()

Motivation

We have no option to get rid of this replacement by the external library. Our current (dirty) workaround is to inject a route, that overwrites the map replacement with another one that is compatible for playwright and the target application.

@yury-s
Copy link
Member

yury-s commented Jan 15, 2025

Are you using some third-party library that overwrites standard Map or is it you in house solution? If you can point to a public website with the problem or share actual example, that'd be helpful. We've addressed a few similar issues in the past with other web APIs that were broken by some popular libraries. We need to understand the scope of the problem here and which Playwright APIs you call, as many parts of the injected script already run in an isolated world and are immune to these kind issues.

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

No branches or pull requests

2 participants