Closed
Description
"SyntaxError: Illegal return statement" may happen on sb.cdp.evaluate(expression)
Simple steps to reproduce:
script = (
f"""
function getSomeValue() {{
return '42';
}}
return getSomeValue();
"""
)
data = sb.cdp.evaluate(script)
The workaround for now is to remove the final return
statement. (Eg. Replace return getSomeValue();
with getSomeValue()
):
script = (
f"""
function getSomeValue() {{
return '42';
}}
getSomeValue();
"""
)
data = sb.cdp.evaluate(script)
That's because sb.cdp.evaluate(expression)
expects a natural expression
(with no return
).