Closed Bug 1390170 Opened 7 years ago Closed 7 years ago

DOMException.prototype should have .message and .name

Categories

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

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: ayg, Assigned: ayg)

Details

Attachments

(1 file)

Accessing DOMException.prototype.name and DOMException.prototype.message directly throws in Chrome and Edge.  This seems correct per spec, because WebIDL defines them as IDL properties of DOMException, and those do throw if you access them directly:

https://heycam.github.io/webidl/#idl-DOMException

Currently we put them on a nonstandard ExceptionMembers interface that DOMException implements.  It might fix things if we just moved these two properties to DOMException itself.
Attachment #8897407 - Flags: review?(bkelly)
Comment on attachment 8897407 [details]
Bug 1390170 - DOMException.prototype should have .message and .name

https://reviewboard.mozilla.org/r/168722/#review174026
Attachment #8897407 - Flags: review?(bkelly) → review+
Pushed by ayg@aryeh.name:
https://hg.mozilla.org/integration/autoland/rev/e596de179468
DOMException.prototype should have .message and .name r=bkelly
https://hg.mozilla.org/mozilla-central/rev/e596de179468
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
I don't understand this change.  ExceptionMembers is implemented by both DOMException and Exception; all its members are installed on the relevant prototypes.  The shared code was shared so we wouldn't duplicate it.

The throwing vs non-throwing was fixed in bug 1378985.

Why did we introduce the code-duplication here?  I can see some value in having the IDL look more like the spec, I guess, but was there any other reason?
Flags: needinfo?(bkelly)
(In reply to Boris Zbarsky [:bz] (still digging out from vacation mail) from comment #5)
> I don't understand this change.  ExceptionMembers is implemented by both
> DOMException and Exception; all its members are installed on the relevant
> prototypes.  The shared code was shared so we wouldn't duplicate it.

Ok.  This wasn't obvious to me reading the webidl.  AFAICT ExceptionMembers was labeled as "legacy" and the proposed patch was bringing us into alignment with the webidl in the specs.

> The throwing vs non-throwing was fixed in bug 1378985.
> 
> Why did we introduce the code-duplication here?  I can see some value in
> having the IDL look more like the spec, I guess, but was there any other
> reason?

I don't object to backing it out, but it might be nice to document how ExceptionMembers works in the webidl.
Flags: needinfo?(bkelly)
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: