Commit d032ec2c authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Decouples DOMException code from DOMException implementation.

As a preparation to move DOMException's exception code into platform/,
this patch decouples the definition of exception code from the
implementation of DOMException class (especially data table).

Also makes the value of exception code match the legacy error code
of DOMException defined in Web IDL.

Bug: 849607
Change-Id: I3044c1ebac8ddb344b3c1d380a08482c57225b30
Reviewed-on: https://chromium-review.googlesource.com/1086955Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564823}
parent cd33f23d
...@@ -12,12 +12,12 @@ enum StorageType { ...@@ -12,12 +12,12 @@ enum StorageType {
kUnknown, kUnknown,
}; };
// These values need to match dom/ExceptionState.h. // These values need to match core/dom/exception_code.h.
enum QuotaStatusCode { enum QuotaStatusCode {
kOk = 0, kOk = 0,
kErrorNotSupported = 7, kErrorNotSupported = 9, // NOT_SUPPORTED_ERR
kErrorInvalidModification = 11, kErrorInvalidModification = 13, // INVALID_MODIFICATION_ERR
kErrorInvalidAccess = 13, kErrorInvalidAccess = 15, // INVALID_ACCESS_ERR
kErrorAbort = 17, kErrorAbort = 20, // ABORT_ERR
kUnknown = -1, kUnknown = -1,
}; };
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
namespace blink { namespace blink {
enum WebIDBDatabaseException { enum WebIDBDatabaseException {
kWebIDBDatabaseExceptionUnknownError = 23, kWebIDBDatabaseExceptionUnknownError = 28,
kWebIDBDatabaseExceptionConstraintError = 24, kWebIDBDatabaseExceptionConstraintError = 29,
kWebIDBDatabaseExceptionDataError = 25, kWebIDBDatabaseExceptionDataError = 30,
kWebIDBDatabaseExceptionVersionError = 28, kWebIDBDatabaseExceptionVersionError = 33,
kWebIDBDatabaseExceptionAbortError = 17, kWebIDBDatabaseExceptionAbortError = 20,
kWebIDBDatabaseExceptionQuotaError = 19, kWebIDBDatabaseExceptionQuotaError = 22,
kWebIDBDatabaseExceptionTimeoutError = 20, kWebIDBDatabaseExceptionTimeoutError = 23,
}; };
} // namespace blink } // namespace blink
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/exception_code.h" #include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink { namespace blink {
...@@ -49,6 +47,9 @@ class CORE_EXPORT DOMException final : public ScriptWrappable { ...@@ -49,6 +47,9 @@ class CORE_EXPORT DOMException final : public ScriptWrappable {
// Constructor exposed to script. // Constructor exposed to script.
static DOMException* Create(const String& message, const String& name); static DOMException* Create(const String& message, const String& name);
static String GetErrorName(ExceptionCode);
static String GetErrorMessage(ExceptionCode);
unsigned short code() const { return code_; } unsigned short code() const { return code_; }
String name() const { return name_; } String name() const { return name_; }
...@@ -64,9 +65,6 @@ class CORE_EXPORT DOMException final : public ScriptWrappable { ...@@ -64,9 +65,6 @@ class CORE_EXPORT DOMException final : public ScriptWrappable {
} }
String ToStringForConsole() const; String ToStringForConsole() const;
static String GetErrorName(ExceptionCode);
static String GetErrorMessage(ExceptionCode);
private: private:
DOMException(unsigned short code, DOMException(unsigned short code,
const String& name, const String& name,
......
...@@ -24,73 +24,85 @@ ...@@ -24,73 +24,85 @@
namespace blink { namespace blink {
// This list must be in sync with |coreExceptions| in DOMExceptions.cpp. // DOMException's error code
// Some of these are considered historical since they have been // https://heycam.github.io/webidl/#idl-DOMException-error-names
// changed or removed from the specifications.
enum { enum {
kIndexSizeError = 1, // DOMExceptions with the legacy error code.
kHierarchyRequestError,
kWrongDocumentError, // The minimum value of the legacy error code of DOMException defined in
kInvalidCharacterError, // Web IDL.
kNoModificationAllowedError, // https://heycam.github.io/webidl/#idl-DOMException
kNotFoundError, kDOMExceptionLegacyCodeMin = 1,
kNotSupportedError,
kInUseAttributeError, // Historical. Only used in setAttributeNode etc which kIndexSizeError = 1, // Deprecated. Use ECMAScript RangeError instead.
// have been removed from the DOM specs. // DOMStringSizeError (= 2) is deprecated and no longer supported.
kHierarchyRequestError = 3,
// Introduced in DOM Level 2: kWrongDocumentError = 4,
kInvalidStateError, kInvalidCharacterError = 5,
kSyntaxError, // NoDataAllowedError (= 6) is deprecated and no longer supported.
kInvalidModificationError, kNoModificationAllowedError = 7,
kNamespaceError, kNotFoundError = 8,
kInvalidAccessError, kNotSupportedError = 9,
kInUseAttributeError = 10, // Historical. Only used in setAttributeNode etc
// Introduced in DOM Level 3: // which have been removed from the DOM specs.
kTypeMismatchError, // Historical; use TypeError instead kInvalidStateError = 11,
// Web IDL 2.7.1 Error names
// XMLHttpRequest extension: // https://heycam.github.io/webidl/#idl-DOMException-error-names
kSecurityError, // Note: Don't confuse the "SyntaxError" DOMException defined here with
// ECMAScript's SyntaxError. "SyntaxError" DOMException is used to report
// Others introduced in HTML5: // parsing errors in web APIs, for example when parsing selectors, while
kNetworkError, // the ECMAScript SyntaxError is reserved for the ECMAScript parser.
kAbortError, kSyntaxError = 12,
kURLMismatchError, kInvalidModificationError = 13,
kQuotaExceededError, kNamespaceError = 14,
kTimeoutError, // kInvalidAccessError is deprecated. Use ECMAScript TypeError for invalid
kInvalidNodeTypeError, // arguments, |kNotSupportedError| for unsupported operations, and
kDataCloneError, // |kNotAllowedError| for denied requests instead.
kInvalidAccessError = 15, // Deprecated.
// The operation failed for an unknown transient reason (e.g. out of memory). // ValidationError (= 16) is deprecated and no longer supported.
// Note: The error message is kTypeMismatchError = 17, // Deprecated. Use ECMAScript TypeError instead.
// "An unknown error occurred within Indexed Database." kSecurityError = 18,
// (defined in third_party/blink/renderer/core/dom/dom_exception.cc) kNetworkError = 19,
// so, this code shouldn't be abused. kAbortError = 20,
kURLMismatchError = 21,
kQuotaExceededError = 22,
kTimeoutError = 23,
kInvalidNodeTypeError = 24,
kDataCloneError = 25,
// The maximum value of the legacy error code of DOMException defined in
// Web IDL.
// https://heycam.github.io/webidl/#idl-DOMException
kDOMExceptionLegacyCodeMax = 25,
// DOMExceptions without the legacy error code.
kEncodingError,
kNotReadableError,
kUnknownError, kUnknownError,
// These are IDB-specific.
kConstraintError, kConstraintError,
kDataError, kDataError,
kTransactionInactiveError, kTransactionInactiveError,
kReadOnlyError, kReadOnlyError,
kVersionError, kVersionError,
kOperationError,
kNotAllowedError,
// File system // The rest of entries are defined out of scope of Web IDL.
kNotReadableError,
kEncodingError,
kPathExistsError,
// SQL
kSQLDatabaseError, // Naming conflict with DatabaseError class.
// Web Crypto // DOMError (obsolete, not DOMException) defined in File system (obsolete).
kOperationError, // https://www.w3.org/TR/2012/WD-file-system-api-20120417/
kPathExistsError,
// Push API // Push API
//
// PermissionDeniedError (obsolete) was replaced with NotAllowedError in the
// standard.
// https://github.com/WICG/BackgroundSync/issues/124
kPermissionDeniedError, kPermissionDeniedError,
kNotAllowedError,
// Pointer Events // Pointer Events
// https://w3c.github.io/pointerevents/
// Pointer Events introduced a new DOMException outside Web IDL.
kInvalidPointerId, kInvalidPointerId,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment