在 Chrome Devtools 协议中,什么是 `injectedScriptId`?

In Chrome Devtools Protocol, what is `injectedScriptId`?

在 CDP 中,例如,当执行 Debugger.evaluateOnCallFrame 以评估某个对象时,响应将包含一个看起来像 {injectedScriptId: 1, id: 413}objectId 属性。 injectedScriptId 永远不会改变(至少我从来没有观察到它改变过)。 id 道具似乎是内存中唯一的对象 ID。

相关(甚至更重要,但只是寻求确认)问题:objectId 中的 id 是对象在整个 program/process 中的唯一标识符吗?我可以依靠它来构建变量的序列化、无循环引用的字符串表示形式吗?

那么 injectedScriptId 的目的是什么,InjectedScript 又是什么?

Answer from JoelEinbinder:

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.