Closed
Bug 1109742
Opened 9 years ago
Closed 9 years ago
[Fetch] Body.json() method should reject promise when parsing body fail
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla38
People
(Reporter: crimsteam, Assigned: nsm)
References
Details
Attachments
(1 file)
6.62 KB,
patch
|
baku
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 Build ID: 20141125180439 Steps to reproduce: Per "consume body" algorithm: https://fetch.spec.whatwg.org/#concept-body-consume-body [Let JSON be the result of invoking the initial value of the parse property of the JSON object with the result of running utf-8 decode on bytes as argument. If that threw an exception, reject p with that exception. Otherwise, resolve p with JSON.] Now, when JSON.parse() faild, Firefox resolve p (but should reject p) and throw to Console: SyntaxError: JSON.parse. Small test: <script> var request1 = new Request(""); request1.json().then(function(data){ // Parsing body faild but this function was invoke // data is undefined // and we get in Console // SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data document.write("Resolve Promies:" + "<br>" + data); }, function(e){ // This should be invoke document.write("Reject Promies:" + "<br>" + e); }); </script>
Assignee | ||
Comment 1•9 years ago
|
||
This is a known bug. Bug dom-fetch-api is blocked on 2 AutoJSAPI fixes (Bug 1072144, Bug 1107777) that are required to fix the issue.
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → nsm.nikhil
Blocks: dom-fetch-api
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee | ||
Comment 2•9 years ago
|
||
It is possible to implement Body.json() correctly using just the autoJSAPIOwnsErrorReporting flag that landed in Bug 1107777.
Assignee | ||
Comment 3•9 years ago
|
||
This relies on the stack class introduced in Bug 1121682.
Attachment #8550451 -
Flags: review?(amarchesini)
Updated•9 years ago
|
Attachment #8550451 -
Flags: review?(amarchesini) → review+
Assignee | ||
Comment 4•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/a1791566f721
Comment 5•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/a1791566f721
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•