New issue
Advanced search Search tips

Issue 780806 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

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:
 

Comment 1 by br...@dockyard.com, Nov 2 2017

If 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}

Comment 2 by br...@dockyard.com, 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

Comment 3 by br...@dockyard.com, 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.
Cc: skyos...@chromium.org
Components: Internals>Headless
Status: WontFix (was: Unconfirmed)
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