Closed Bug 1261904 Opened 8 years ago Closed 8 years ago

Refactor Debugger.Object.getErrorMessageName

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: mrrrgn, Assigned: mrrrgn)

References

Details

Attachments

(1 file, 4 obsolete files)

This API doesn't make proper use of the Debugger object. In short, this method should not take an argument.
Assignee: nobody → winter2718
Blocks: 1259563
Sorry I didn't do a better job reviewing that patch!
(In reply to Morgan Phillips [:mrrrgn] from comment #0)
> This API doesn't make proper use of the Debugger object. In short, this
> method should not take an argument.

It shouldn't take an argument, and it should possibly be just an accessor property of the Debugger.Object (see DebuggerObject_properties).
Attached patch getErrorMsgName.diff (obsolete) — Splinter Review
(In reply to Jim Blandy :jimb from comment #2)
> (In reply to Morgan Phillips [:mrrrgn] from comment #0)
> > This API doesn't make proper use of the Debugger object. In short, this
> > method should not take an argument.
> 
> It shouldn't take an argument, and it should possibly be just an accessor
> property of the Debugger.Object (see DebuggerObject_properties).

Yeah, 100% agree about it being a property.
Attached patch getErrorMsgName.diff (obsolete) — Splinter Review
Attachment #8738287 - Attachment is obsolete: true
Attachment #8738317 - Flags: review?(jimb)
Attached patch getErrorMsgName.diff (obsolete) — Splinter Review
Attachment #8738317 - Attachment is obsolete: true
Attachment #8738317 - Flags: review?(jimb)
Attachment #8738319 - Flags: review?(jimb)
Comment on attachment 8738319 [details] [diff] [review]
getErrorMsgName.diff

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

Tests are excellent. One minor issue to address.

::: js/src/vm/Debugger.cpp
@@ +8039,5 @@
> +    THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, "get errorMessageName", args, referent);
> +
> +    JSObject* obj = referent;
> +    if (IsCrossCompartmentWrapper(obj))
> +        obj = CheckedUnwrap(obj);

It looks to me like CheckedUnwrap can return nullptr if the unwrap isn't permitted. If this happens, the is<ErrorObject> check will segfault. We need to report an error on cx and return false; see how Debugger::unwrapDebuggeeArgument checks the return value from its call to CheckedUnwrap for an example to emulate.
Attachment #8738319 - Flags: review?(jimb) → review-
(In reply to Jim Blandy :jimb from comment #7)
> Comment on attachment 8738319 [details] [diff] [review]
> getErrorMsgName.diff
> 
> Review of attachment 8738319 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Tests are excellent. One minor issue to address.
> 
> ::: js/src/vm/Debugger.cpp
> @@ +8039,5 @@
> > +    THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, "get errorMessageName", args, referent);
> > +
> > +    JSObject* obj = referent;
> > +    if (IsCrossCompartmentWrapper(obj))
> > +        obj = CheckedUnwrap(obj);
> 
> It looks to me like CheckedUnwrap can return nullptr if the unwrap isn't
> permitted. If this happens, the is<ErrorObject> check will segfault. We need
> to report an error on cx and return false; see how
> Debugger::unwrapDebuggeeArgument checks the return value from its call to
> CheckedUnwrap for an example to emulate.

Oy vey, fixing it up. Thanks !

https://49.media.tumblr.com/38430f1e34abf51dc21bd62bdc7f2063/tumblr_myy2yekXjj1rrx588o1_500.gif
Attached patch getErrorMsgName.diff (obsolete) — Splinter Review
Attachment #8738319 - Attachment is obsolete: true
Attachment #8738366 - Attachment is obsolete: true
Attachment #8738391 - Flags: review?(jimb)
Comment on attachment 8738391 [details] [diff] [review]
getErrorMsgName.diff

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

Looks great, thanks!
Attachment #8738391 - Flags: review?(jimb) → review+
https://hg.mozilla.org/mozilla-central/rev/4b76e05f7ecf
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Depends on: 1270721
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: