Question: what is injectedScriptId (lacking documentation)?
See original GitHub issueReposting a StackOverflow question here (because got no answer there):
In CDP, when, for example, executing Debugger.evaluateOnCallFrame in order to evaluate some object, the response will contain an objectId
property that looks like {injectedScriptId: 1, id: 413}
. And the injectedScriptId
never changes (at least I’ve never observed it changed). The id
prop seems to be a unique object id in the memory.
So what’s the purpose of the injectedScriptId
and what is InjectedScript
?
Related (even more important, but simply seeking confirmation) question: is the id
in objectId
a unique identifier of the object across the whole program/process? Can I rely on it in order to build a serialized, circular-reference-free string representation of variables?
Help me please!
P.S. Maybe the answer should also go to the documentation.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top GitHub Comments
This is an internal implementation detail so you shouldn’t rely on it and it may change at any time without warning, or not behave consistently.
Injected script is the internal thing that we inject into a JavaScript execution context to manage remote objects and other things. That’s why they have separate id counters.
So no, the internal id is not unique. Use the string.
@JoelEinbinder The hack you mentioned has some race condition issue. I hope the chrome team can add an official endpoint for it. Since it’s pretty useful to check if an object is inside an iframe or not. And the playwright is using
injectedScriptId
? https://github.com/microsoft/playwright/blob/be16ce4bd200be6e38f542321336f816fa19575f/src/server/webkit/wkPage.ts#L484