Bug 1390170 - DOMException.prototype should have .message and .name
The spec requires that they be interface members:
https://heycam.github.io/webidl/#idl-DOMException
This means they're on the prototype. This change brings us in line with
Chrome, Edge, and WebKit, as tested by
<https://github.com/w3c/web-platform-tests/pull/6875>.
MozReview-Commit-ID: A1cKpmlCNCs
--- a/dom/webidl/DOMException.webidl
+++ b/dom/webidl/DOMException.webidl
@@ -14,22 +14,18 @@
// This is the WebIDL version of nsIException. This is mostly legacy stuff.
interface StackFrame;
[NoInterfaceObject,
Exposed=(Window,Worker)]
interface ExceptionMembers
{
- // A custom message set by the thrower.
- readonly attribute DOMString message;
// The nsresult associated with this exception.
readonly attribute unsigned long result;
- // The name of the error code (ie, a string repr of |result|).
- readonly attribute DOMString name;
// Filename location. This is the location that caused the
// error, which may or may not be a source file location.
// For example, standard language errors would generally have
// the same location as their top stack entry. File
// parsers may put the location of the file they were parsing,
// etc.
@@ -52,28 +48,38 @@ interface ExceptionMembers
// Formatted exception stack
[Throws, Replaceable]
readonly attribute DOMString stack;
};
[NoInterfaceObject, Exposed=(Window,Worker)]
interface Exception {
+ // The name of the error code (ie, a string repr of |result|).
+ readonly attribute DOMString name;
+ // A custom message set by the thrower.
+ readonly attribute DOMString message;
// A generic formatter - make it suitable to print, etc.
stringifier;
};
Exception implements ExceptionMembers;
// XXXkhuey this is an 'exception', not an interface, but we don't have any
// parser or codegen mechanisms for dealing with exceptions.
[ExceptionClass,
Exposed=(Window, Worker),
Constructor(optional DOMString message = "", optional DOMString name)]
interface DOMException {
+ // The name of the error code (ie, a string repr of |result|).
+ readonly attribute DOMString name;
+ // A custom message set by the thrower.
+ readonly attribute DOMString message;
+ readonly attribute unsigned short code;
+
const unsigned short INDEX_SIZE_ERR = 1;
const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
const unsigned short HIERARCHY_REQUEST_ERR = 3;
const unsigned short WRONG_DOCUMENT_ERR = 4;
const unsigned short INVALID_CHARACTER_ERR = 5;
const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical
const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
const unsigned short NOT_FOUND_ERR = 8;
@@ -89,15 +95,13 @@ interface DOMException {
const unsigned short SECURITY_ERR = 18;
const unsigned short NETWORK_ERR = 19;
const unsigned short ABORT_ERR = 20;
const unsigned short URL_MISMATCH_ERR = 21;
const unsigned short QUOTA_EXCEEDED_ERR = 22;
const unsigned short TIMEOUT_ERR = 23;
const unsigned short INVALID_NODE_TYPE_ERR = 24;
const unsigned short DATA_CLONE_ERR = 25;
-
- readonly attribute unsigned short code;
};
// XXXkhuey copy all of Gecko's non-standard stuff onto DOMException, but leave
// the prototype chain sane.
DOMException implements ExceptionMembers;