Re: [w3c/browser-payment-api] The myth of JSON-serializable object (#307)

I'm trying to understand the fundamental difference of opinion here, please bear with me.

Is there a concern that `JSON.parse/stringify` behavior isn't precisely specified by [ECMA 262](https://tc39.github.io/ecma262/#sec-json.parse) and [ECMA 404](https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf)?  From a naive skim of those specs it seems to me like they do precisely define which "objects can be serialized to a string using JSON.stringify and later deserialized back to an object using JSON.parse with no loss of data" (although "no loss of data" should probably be precisely defined with an algorithm, but I suspect we can all agree on what that algorithm would be).

Or is the concern that, despite being precisely specified, the definition is complex and so it's hard to get a conforming implementation in this context (and so existing implementations likely already don't conform to that definition)?  

FWIW the [blink implementation](https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp?dr&sq=package:chromium&rcl=1480493940&l=460) appears to rely just on our JSON.stringify method succeeding.  So the main opportunities I'd see for this not to conform to the above rough definition are:

- Cases where stringify generates a string which will fail to parse (hopefully not allowed by the spec).
- Cases where stringify generates a string which, when parsed, produces a different object.

So we definitely have conformance bugs in blink (`data:{a:undefined}` and `data:{a:navigator}` should throw but don't in blink).  I've filed [this implementation issue](https://bugs.chromium.org/p/chromium/issues/detail?id=669959).

Perhaps the primary issue for the WG here is conformance testing?  If the definition is written is in fact mostly OK, how should we thoroughly test it such that bugs like blink's would be caught?  Could we leverage the [test262 JSON tests](https://github.com/tc39/test262/tree/master/test/built-ins/JSON) at all?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/browser-payment-api/issues/307#issuecomment-263940670

Received on Wednesday, 30 November 2016 17:39:16 UTC