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)
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)
(deleted),
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
This is needed for both JS-implemented DOM stuff and for NodeFilter in bug 838686.
Assignee | ||
Comment 1•12 years ago
|
||
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.
Assignee | ||
Comment 2•12 years ago
|
||
Just posting this for now so it's up somewhere
Assignee | ||
Comment 3•12 years ago
|
||
Assignee | ||
Comment 4•12 years ago
|
||
Assignee | ||
Comment 6•12 years ago
|
||
I do wonder what happens if that script reenters other APIs.... :(
Assignee | ||
Updated•12 years ago
|
Attachment #712076 -
Attachment is obsolete: true
Assignee | ||
Comment 7•12 years ago
|
||
> 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.
Assignee | ||
Comment 8•12 years ago
|
||
Attachment #712204 -
Flags: review?(peterv)
Assignee | ||
Updated•12 years ago
|
Attachment #712075 -
Attachment is obsolete: true
Assignee | ||
Comment 9•12 years ago
|
||
Attachment #712205 -
Flags: review?(peterv)
Assignee | ||
Updated•12 years ago
|
Attachment #712078 -
Attachment is obsolete: true
Assignee | ||
Comment 10•12 years ago
|
||
Attachment #712206 -
Flags: review?(peterv)
Assignee | ||
Updated•12 years ago
|
Attachment #712077 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Whiteboard: [need review]
Comment 11•12 years ago
|
||
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 12•12 years ago
|
||
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 13•12 years ago
|
||
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+
Assignee | ||
Comment 14•12 years ago
|
||
> 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.
Assignee | ||
Comment 15•12 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/313c30fbb1fa
https://hg.mozilla.org/integration/mozilla-inbound/rev/8832678a13db
https://hg.mozilla.org/integration/mozilla-inbound/rev/f71e6d7c7ea3
Whiteboard: [need review]
Comment 16•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/313c30fbb1fa
https://hg.mozilla.org/mozilla-central/rev/8832678a13db
https://hg.mozilla.org/mozilla-central/rev/f71e6d7c7ea3
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
Assignee | ||
Comment 17•12 years ago
|
||
Documented at https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Callback_function_types and https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Interface_types
Keywords: dev-doc-complete
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•