Closed Bug 1383158 Opened 7 years ago Closed 7 years ago

[jsdbg2] Documentation should explain when Debugger.Object.prototype.isExtensible and friends may throw

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: jimb, Assigned: jimb)

References

Details

Attachments

(1 file)

The Debugger API documentation doesn't make it clear that methods for inspecting objects, like isExtensible or isSealed, may throw when applied to exotic (but not rare) object types like cross-process object wrappers or opaque wrappers.

The purpose of D.O is to provide a useful API for inspecting objects, so it's arguable whether they should throw at all. But it's not clear what they *should* do when applied to, say, an opaque wrapper. Propagating the exception at least ensures that the caller gets all the information available about what went wrong.
Assignee: nobody → jimb
Nick Fitzgerald (:fitzgen) suggests that we should just admit the reality of the situation, and treat isExtensible and friends as invocation functions, methods that could potentially run debuggee code like Debugger.Frame.prototype.eval or Debugger.Object.prototype.call. Rather than simply returning true or false, they would return a completion value like { return: true } or { throw: ERR }.

This would be a pain to use.

But the job of Debugger is not to paper over messy reality: it's to help people write correct servers, *given* whatever reality is like. Our reality includes CPOWs and opaque wrappers and proxies. Returning resumption values would have alerted the server authors here to be prepared for all the possibilities. The current design invited them to ignore the possibility that all hell could break loose.
Comment on attachment 8893529 [details] [diff] [review]
Document that Debugger.Object methods may throw on exotic objects.

Review of attachment 8893529 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks.  This looks good.
Attachment #8893529 - Flags: review?(ttromey) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/6b2feb00e025
Document that Debugger.Object methods may throw on exotic objects. r=tromey
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6b2feb00e025
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: