How to access remote objects IDs?

2,351 views
Skip to first unread message

masoomeh Rudafshani

unread,
Aug 2, 2011, 3:08:29 PM8/2/11
to Google Chrome Developer Tools
Hi,
I'm trying to use Runtime domain for Remote Debugging. As stated in
the documentation (http://code.google.com/chrome/devtools/docs/
protocol/runtime.html#type-RemoteObject), all the functions need to be
passed objectId. Where can I get objectId at first place?
Thanks,
Masoomeh

Andrey Kosyakov

unread,
Aug 2, 2011, 3:20:34 PM8/2/11
to google-chrome-...@googlegroups.com
Runtime.evaluate and Runtime.callFunctionOn return a RemoteObject that has objectId filed, in case the expression has evaluated into an Object. Further object identifiers will be returned for the object's properties if you enumerate them via Runtime.getProperties.

Best regards,
Andrey.

masoomeh Rudafshani

unread,
Aug 2, 2011, 3:35:32 PM8/2/11
to Google Chrome Developer Tools
But even for those two functions (Runtime.evaluate and
Runtime.callFunctionOn), it is needed to pass objectId as a parameter
because one of the parameters for callFunctionOn is "objectId":
<RemoteObjectId>.

Thanks,
Masoomeh

On Aug 2, 3:20 pm, Andrey Kosyakov <ca...@chromium.org> wrote:
> Runtime.evaluate and Runtime.callFunctionOn return a RemoteObject that has
> objectId filed, in case the expression has evaluated into an Object. Further
> object identifiers will be returned for the object's properties if you
> enumerate them via Runtime.getProperties.
>
> Best regards,
> Andrey.
>
> On Tue, Aug 2, 2011 at 11:08 PM, masoomeh Rudafshani <
>

Andrey Kosyakov

unread,
Aug 2, 2011, 3:43:29 PM8/2/11
to google-chrome-...@googlegroups.com
That's true for Runtime.callFunctionOn, but Runtime.evaluate does not need an object id.

Best regards,
Andrey.

masoomeh Rudafshani

unread,
Aug 2, 2011, 3:55:58 PM8/2/11
to Google Chrome Developer Tools

But it needs objectGroup or expression to evaluate on. What I need to
do is to access and manipulate JavaScript objects in a remote page.

Thanks,
Masoomeh

On Aug 2, 3:43 pm, Andrey Kosyakov <ca...@chromium.org> wrote:
> That's true for Runtime.callFunctionOn, but Runtime.evaluate does not need
> an object id.
>
> Best regards,
> Andrey.
>
> On Tue, Aug 2, 2011 at 11:35 PM, masoomeh Rudafshani <
>

Andrey Kosyakov

unread,
Aug 2, 2011, 4:33:32 PM8/2/11
to google-chrome-...@googlegroups.com

objectGroup is just an arbitrary, client-supplied string -- you can use anything, its only purpose is managing life-time of evaluated objects with releaseObjectGroup.

Expression may be as simple as the name of the object you want to examine - essentially similar to what you would do in the DevTools console.

On Aug 2, 2011 11:56 PM, "masoomeh Rudafshani" <masoomeh....@gmail.com> wrote:

pfeldman

unread,
Aug 2, 2011, 4:43:56 PM8/2/11
to Google Chrome Developer Tools
A couple of additional notes: objectGroup is optional, you don't have
to provide it.
Expresion is required - you need to start with something. You can
evaluate entire function bodies along with their calls. As Andrey
suggests, you should experiment in the DevTools console before issuing
the expressions using the protocol for ease of debugging. When using
Runtime domain, you need to start with the objects that are reachable
from the global object (window). You can evaluate "document" (which is
"window.document") or "localStorage", etc. Then you have handles to
the results of the evaluation that you can use in your further calls.

Regards
Pavel
> masoomeh.rudafsh...@gmail.com> wrote:

masoomeh Rudafshani

unread,
Aug 3, 2011, 2:19:28 PM8/3/11
to Google Chrome Developer Tools

Thanks for the info, but I have some more questions:
1) How can one issue commands such as Runtime.getProperties and
Runtime.evaluate in console as there is no panel for runtime?
2) How can I access the JavaScript objects of a page? Right now I
tried passing "document" and it does not contain any info about the
JavaScript objects of the page.
3) What are the other options that I can pass to "expression" argument
(I mean other than "document" and "localstorage")? Is there anywhere
on the code that I can look to get more info as the documentation does
not have such info.

Thanks,
Masoomeh

Andrey Kosyakov

unread,
Aug 3, 2011, 2:55:43 PM8/3/11
to google-chrome-...@googlegroups.com
On Wed, Aug 3, 2011 at 10:19 PM, masoomeh Rudafshani <masoomeh....@gmail.com> wrote:

Thanks for the info, but I have some more questions:
1) How can one issue commands such as Runtime.getProperties and
Runtime.evaluate in console as there is no panel for runtime?

You won't be able to issue DevTools protocol commands via the console. However, the DevTools console internally uses Runtime.evaluate to evaluate expressions entered in console within the inspected page. So the idea is that you can just experiment with the expressions you'll be passing to Runtime.evaluate in the console.

2) How can I access the JavaScript objects of a page? Right now I
tried passing "document" and it does not contain any info about the
JavaScript objects of the page.

The global objects of the page are properties of the window objects -- so in case you need to enumerate all global objects, you just use "window" as an expression and enumerate its properties.

3) What are the other options that I can pass to "expression" argument
(I mean other than "document" and "localstorage")? Is there anywhere
on the code that I can look to get more info as the documentation does
not have such info.

These are not any special options, these are just JavaScript expressions. "document" and "localStorage" are just properties of the window object. Type "window" at console to explore global symbols.

Best regards,
Andrey.

masoomeh

unread,
Nov 23, 2011, 8:22:16 PM11/23/11
to Andrey Kosyakov, google-chrome-...@googlegroups.com
Hi there,
I'm trying to use Runtime.releaseObject to delete objects from a page.
I use Runtime.evaluate as discussed before in these emails to find the
object and objectId and then call Runtime.releaseObject on that
object.
I expect the memory of the object to be released. Also I expect if I
use Runtime.evaluate again to find the object, it does not find it
again. But neither of this happens; not the memory is released not the
object is deleted. Calling the function again can find the
corrresponding object.
Any help in this regard would be appreciated.
Masoomeh

On Aug 3, 1:55 pm, Andrey Kosyakov <ca...@chromium.org> wrote:
> On Wed, Aug 3, 2011 at 10:19 PM, masoomeh Rudafshani <
>

Andrey Kosyakov

unread,
Nov 24, 2011, 12:38:11 AM11/24/11
to masoomeh, google-chrome-...@googlegroups.com
On Thu, Nov 24, 2011 at 5:22 AM, masoomeh <masoomeh....@gmail.com> wrote:
> Hi there,
> I'm trying to use Runtime.releaseObject to delete objects from a page.
> I use Runtime.evaluate as discussed before in these emails to find the
> object and objectId and then call Runtime.releaseObject on that
> object.
> I expect the memory of the object to be released. Also I expect if I
> use Runtime.evaluate again to find the object, it does not find it
> again. But neither of this happens; not the memory is released not the
> object is deleted. Calling the function again can find the
> corrresponding object.
> Any help in this regard would be appreciated.

Runtime.releaseObject() does not directly affect the user-created
object, it just releases the wrapper object that the inspector
maintains to provide the debugger with access to the properties of the
object produced as a result of Runtime.evaluate(). The only way to
actually reclaim the memory of the user object is to have all
references to the object removed (which also includes
Runtime.releaseObject() for all objects that refer to that object and
that were ever evaluated).

Best regards,
Andrey.

Masoomeh Rudafshani

unread,
Nov 24, 2011, 9:28:47 AM11/24/11
to Andrey Kosyakov, google-chrome-...@googlegroups.com
Thanks,
So, is there a way to remove all references to an object during run-time?

Or do you have any idea what I need to do if I want to set null to an object during runtime so that it is assumed part of the JavaScript code of the page?
Reply all
Reply to author
Forward
0 new messages