Closed Bug 1121682 Opened 10 years ago Closed 10 years ago

fetch() should reject on network error with a TypeError

Categories

(Core :: DOM: Core & HTML, defect)

33 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(1 file, 1 obsolete file)

Instead of resolving with a network error Response.
Attached patch fetch() should reject with TypeError (obsolete) (deleted) — Splinter Review
Fetch spec section 5.6, step 3.1.
Attachment #8549163 - Flags: review?(bkelly)
Assignee: nobody → nsm.nikhil
Status: NEW → ASSIGNED
Comment on attachment 8549163 [details] [diff] [review] fetch() should reject with TypeError I'm sorry, but I don't feel comfortable enough with jsapi stuff to review this. Redirect to Andrea.
Attachment #8549163 - Flags: review?(bkelly) → review?(amarchesini)
For reference, Bug 1107777 introduced the JSContext option I'm using.
So I guess I'm curious if you're saying that bug 1091091 was implemented incorrectly? Can you or some explain why Promise::MaybeReject(ErrorResult) doesn't work here?
Flags: needinfo?(nsm.nikhil)
(In reply to Ben Kelly [:bkelly] from comment #4) > So I guess I'm curious if you're saying that bug 1091091 was implemented > incorrectly? Can you or some explain why Promise::MaybeReject(ErrorResult) > doesn't work here? It only doesn't work when ErrorResult has failed with a TypeError. ToJSValue calls https://dxr.mozilla.org/mozilla-central/source/dom/bindings/BindingUtils.h#105 which leads to JS_ReportErrorNumberUCArray being called, which goes via the "Let's report instead of setting an exception on the cx, unless this flag is set or JS is running". If we always want to capture the error in ToJSValue, we should set the JSContext flag inside it.
Flags: needinfo?(nsm.nikhil)
Can we push down the cx option munging into the ToJSValue overload for ErrorResult, instead, please? I can't wait for the SpiderMonkey folks to fix their exception story....
Boris for JSAPI bits, Ben for making sure I'm following the fetch spec. Boris, I've put the class in Exceptions.h instead of ToJSValue.h since I also want to use it in Bug 1109742 in the dom/fetch/Fetch.cpp file. Is that ok?
Attachment #8551932 - Flags: review?(bzbarsky)
Attachment #8551932 - Flags: review?(bkelly)
Attachment #8549163 - Attachment is obsolete: true
Attachment #8549163 - Flags: review?(amarchesini)
Comment on attachment 8551932 [details] [diff] [review] fetch() should reject with TypeError >+++ b/dom/bindings/Exceptions.h >+// Throwing a TypeError on an ErrorResult may result in Spidermonkey using its Nix the extra space before "SpiderMonkey" (and note the casing). >+++ b/dom/bindings/ToJSValue.cpp >- > } // namespace tojsvalue_detail Please leave that blank line. >+ AutoForceSetExceptionOnContext forceExn(aCx); Just out of curiosity, did the MOZ_ASSERT that JS_GetPendingException returns true fail without this patch? I really hope it did... >+++ b/dom/fetch/Fetch.cpp >+ AutoSafeJSContext cx; This is unused, right? Please ditch it. r=me. Thank you for fixing this!
Attachment #8551932 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky [:bz] from comment #8) > Comment on attachment 8551932 [details] [diff] [review] > fetch() should reject with TypeError > > >+++ b/dom/bindings/Exceptions.h > >+// Throwing a TypeError on an ErrorResult may result in Spidermonkey using its > > Nix the extra space before "SpiderMonkey" (and note the casing). > > >+++ b/dom/bindings/ToJSValue.cpp > >- > > } // namespace tojsvalue_detail > > Please leave that blank line. > > >+ AutoForceSetExceptionOnContext forceExn(aCx); > > Just out of curiosity, did the MOZ_ASSERT that JS_GetPendingException > returns true fail without this patch? I really hope it did... Yes it did.
Attachment #8551932 - Flags: review?(bkelly) → review+
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: