Closed Bug 839088 Opened 12 years ago Closed 12 years ago

Add infrastructure for being able to not report errors immediately but instead propagate them out when a WebIDL callback returns

Categories

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

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(3 files, 4 obsolete files)

This is needed for both JS-implemented DOM stuff and for NodeFilter in bug 838686.
As a note to self: 1) Add a flag to CallSetup and an optional argument to callback methods. 2) When the flag is in use, set JSOPTION_DONT_REPORT_UNCAUGHT on the JSContext for the duration of the call. 3) When the flag is in use, instead of reporting the exception, JS_GetPendingException and stash it in the ErrorResult so that it can be rethrown as needed.
Blocks: 776536
Just posting this for now so it's up somewhere
Stil need to do item #2 from comment 1.
Attached patch Part 2 now with the context options bit. (obsolete) (deleted) — Splinter Review
I do wonder what happens if that script reenters other APIs.... :(
Attachment #712076 - Attachment is obsolete: true
> I do wonder what happens if that script reenters other APIs.... :( Can't be any worse than nsXPCWrappedJSClass::CallMethod, since that does the same context flag.
Attachment #712075 - Attachment is obsolete: true
Attachment #712078 - Attachment is obsolete: true
Attachment #712077 - Attachment is obsolete: true
Whiteboard: [need review]
Comment on attachment 712204 [details] [diff] [review] part 1. Add a way to throw a JS::Value on an ErrorResult. Review of attachment 712204 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/BindingUtils.cpp @@ +63,5 @@ > va_start(ap, errorNumber); > + if (IsJSException()) { > + // We have rooted our mJSException, and we don't have the info > + // needed to unroot here, so just bail. > + va_end(ap); Is this missing a return? I'm going to assume it is. Do we want to assert here like in the operator=? We're silently dropping the type error on the floor. ::: dom/bindings/ErrorResult.h @@ +106,5 @@ > > private: > nsresult mResult; > struct Message; > // Do not use nsAutoPtr to avoid extra initalizatoin and check. I think you could just delete this comment now. @@ +112,5 @@ > + // ReportTypeError. > + union { > + Message* mMessage; > + JS::Value mJSException; > + }; Document the mResult values that determine which member of the union to use. ::: xpcom/base/ErrorList.h @@ +547,5 @@ > ERROR(NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED, FAILURE(1011)), > ERROR(NS_ERROR_DOM_BAD_URI, FAILURE(1012)), > ERROR(NS_ERROR_DOM_RETVAL_UNDEFINED, FAILURE(1013)), > ERROR(NS_ERROR_DOM_QUOTA_REACHED, FAILURE(1014)), > + ERROR(NS_ERROR_JS_EXCEPTION, FAILURE(1015)), Do we need _DOM_ in there?
Attachment #712204 - Flags: review?(peterv) → review+
Comment on attachment 712205 [details] [diff] [review] part 2. Add way to indicate to a CallSetup that it should propagate any exceptions thrown during the call out to the ErrorResult for the call. Review of attachment 712205 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/CallbackObject.cpp @@ +156,5 @@ > + } > + > + if (!dealtWithPendingException) { > + // Presumably we failed to JS_GetPendingException. I guess we > + // just report it. This comment only applies if |mExceptionHandling == eRethrowExceptions|, maybe you should mention that.
Attachment #712205 - Flags: review?(peterv) → review+
Comment on attachment 712206 [details] [diff] [review] part 3. Add a way for callers of callback methods to ask for any exceptions from the callback to be rethrown on the ErrorResult. Review of attachment 712206 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/Codegen.py @@ +717,3 @@ > def define(self): > return "" if self.inline else self._define() > + def definition_prologue(self, fromDeclare=False): Can you drop the default value for fromDeclare here?
Attachment #712206 - Flags: review?(peterv) → review+
> Is this missing a return? Yes, good catch. > Do we want to assert here like in the operator=? Sure. Kept the safe bailing code, but made it assert. > Document the mResult values that determine which member of the union to use. Documented that IsTypeError() and IsJSException() are what make those union members valid. > Do we need _DOM_ in there? I guess it can't hurt. Added. > This comment only applies if |mExceptionHandling == eRethrowExceptions|, maybe you > should mention that. Done: // Either we're supposed to report our exceptions, or we're supposed to // re-throw them but we failed to JS_GetPendingException. Either way, // just report the pending exception, if any. > Can you drop the default value for fromDeclare here? Done.
Depends on: 846955
Depends on: 856428
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: