Closed janodvarko closed 7 years ago
In order to see the error in the Browser console you can do the following:
chrome.devtools.inspectedWindow.eval(expr, (result, error) => {
if (error) {
console.log("error ", error);
} else {
console.log("result ", result);
}
appendLog(expr, result, error);
});
@rpl any tips?
Honza
@janodvarko yep, it is part of the expected behavior:
the inspectedWindow.eval
returns the result of the evaluated code to the caller over the remote debugging protocol, if the eval result cannot be serialized to JSON, a protocol error have to be returned.
e.g. while chrome.devtools.inspectedWindow.eval("window", (result, error) => {})
will result into a protocol error, chrome.devtools.inspectedWindow.eval("window.location", (result, error) => {})
should work fine (because there is no cyclic object reference that prevents it to be serialized to JSON)
There are basically two kind of errors that can happens during a inspectedWindow.eval
call:
error.isException
is true
, and the failure is occurred in the evaluated code)error.isError
is true
, and the failure is occurred on the DevTools side)More info on this behavior can be found in the related Chrome API docs: https://developer.chrome.com/extensions/devtools_inspectedWindow#method-eval
I see, thanks for the info! Honza
This issue is related to 'console' example.
I am getting the following error when evaluating
window
expression in the inspected window.Inspector protocol error: TypeError: cyclic object value
The related code is here: https://github.com/devtools-html/extension-examples/blob/master/console/panel.js#L18
STR: 1) Install the Console example 2) Open the Toolbox and select 'MyConsole' panel 3) Type
window
in the command line and press Enter key 4) The result says undefined and there is the aforementioned errorHonza