Headless Runtime.evaluate not returnByValue JSON literals
Reported by
br...@dockyard.com,
Nov 2 2017
|
|||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.18 Safari/537.36
Steps to reproduce the problem:
1. Send the following to headless: {"params":{"returnByValue":true,"expression":"{a:1}"},"method":"Runtime.evaluate","id":8}
2.
3.
What is the expected behavior?
I would expect the JSON literal {a: 1} to be the return value
What went wrong?
Instead the return value is the number 1
Did this work before? N/A
Does this work in other browsers? N/A
Chrome version: 63.0.3239.18 Channel: canary
OS Version: OS X 10.12.6
Flash Version:
,
Nov 2 2017
Evaluating a JSON literal with `new Object()` does work however:
{"params":{"returnByValue":true,"expression":"new Object({a: 1, b: 2})"},"method":"Runtime.evaluate","id":19}
this returns: {"a": 1, "b": 2} as I would expect
,
Nov 2 2017
The result of a promise will also work with a literal JSON:
{"params":{"returnByValue":true,"expression":"Promise.resolve({a: 1, b: 2})","awaitPromise":true},"method":"Runtime.evaluate","id":22}
I get back {"a": 1, "b": 2}
So it looks like a blocking eval for a JSON literal is the only case that isn't working at the moment.
,
Nov 2 2017
,
Nov 3 2017
This is a "feature" of JavaScript, eval("{a: 1}") returns 1 because the braces are interpreted as markers of blocks of code instead of an object literal. Try adding braces: "({a: 1})"
|
|||
►
Sign in to add a comment |
|||
Comment 1 by br...@dockyard.com
, Nov 2 2017If you try to evaluate a multi-key json literal it returns "SyntaxError: Unexpected token :" {"params":{"returnByValue":true,"expression": {a:1, b:2}"},"method":"Runtime.evaluate","id":8}