Closed Bug 1096341 Opened 10 years ago Closed 10 years ago

ToJSValue overload returns false without setting exception

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: tromey, Assigned: tromey)

References

Details

Attachments

(1 file)

The ToJSValue contract says:

// If ToJSValue returns false, it must set an exception on the
// JSContext.


However the last overload in ToJSValue.cpp does:

  if (!JS_GetPendingException(aCx, aValue)) {
    return false;
  }

... returning false when no exception is pending.
So if JS_GetPendingException returned false then either:

1)  ThrowMethodFailedWithDetails somehow failed to throw an exception

or

2)  JSContext::getPendingException returned false without throwing.

The latter can only happen if wrap() returns false without throwing, which it shouldn't.

So I expect that JS_GetPendingException can never actually return false here... but falling back to undefined and returning true if it does return false might not be insane.  Can't think of any better options.
Another option might be to simply assert that ThrowMethodFailedWithDetails
did what it said it was going to do.  It also seems to me that
JS_GetPendingException can't return false here.
Here's what I was thinking for the assertion approach.
Yes, that would make sense to me.
Assignee: nobody → ttromey
Comment on attachment 8520011 [details] [diff] [review]
require an exception to be set in ToJSValue overload

The test results look good.
I wasn't sure if that previous comment constituted a review,
so marking for review on the assumption it was not :)
Attachment #8520011 - Flags: review?(bzbarsky)
Comment on attachment 8520011 [details] [diff] [review]
require an exception to be set in ToJSValue overload

r=me
Attachment #8520011 - Flags: review?(bzbarsky) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6cec52c43496
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
Depends on: 1099591
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: