I am connected to Chrome (34.0.1847.132) via the Remote Debugging Protocol, and I have successfully enabled runtime and console debugging. I can send Chrome messages and will get the responses back.
Now, I'd like to inspect the properties of a certain JavaScript variable in the current page. So, in my HTML page, I have the following statement in a script tag:
window.foo = {
'bar' : 'baz'
}
I can query the property with window.foo.bar from the console in Chrome itself, but I cannot do it via remote debugging, since I receive an error.
To get the property, I send this JSON message to the WebSocket:
{
:method => "Runtime.getProperties",
:params => {
:objectId => "window.foo.bar"
},
"id"=>2
}
And I get the response:
{
"error" => {
"code" => -32000,
"message" => "Inspected frame has gone"
},
"id" => 2
}
Similarly, if I try to Runtime.evaluate the expression window.foo.bar, I get:
{
"result" => {
"result" => {
"type" => "object",
"objectId" => "{\"injectedScriptId\":1,\"id\":1}",
"className" => "TypeError",
"description" => "TypeError: Cannot read property 'bar' of undefined"
},
"wasThrown" => true
},
"id" => 2
}
What would cause the "inspected frame" to be gone? What is that, even?
Or is the objectId something completely different?
How do I access the property of a JavaScript variable then?