Commit 56b2cd4a authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Improve error messages of named properties

Adds an interface name to error messages when named properties
access fails.

Bug: 839389
Change-Id: I7d7df7ba5c41d25d85d0b86c60d6a073d1bc58e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377830Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802175}
parent 5063d69d
...@@ -97,6 +97,23 @@ String ExceptionMessages::FailedToDeleteIndexed(const char* type, ...@@ -97,6 +97,23 @@ String ExceptionMessages::FailedToDeleteIndexed(const char* type,
"': " + detail; "': " + detail;
} }
String ExceptionMessages::FailedToGetNamed(const char* type,
const String& detail) {
return "Failed to read a named property from '" + String(type) +
"': " + detail;
}
String ExceptionMessages::FailedToSetNamed(const char* type,
const String& detail) {
return "Failed to set a named property on '" + String(type) + "': " + detail;
}
String ExceptionMessages::FailedToDeleteNamed(const char* type,
const String& detail) {
return "Failed to delete a named property from '" + String(type) +
"': " + detail;
}
String ExceptionMessages::ConstructorNotCallableAsFunction(const char* type) { String ExceptionMessages::ConstructorNotCallableAsFunction(const char* type) {
return FailedToConstruct(type, return FailedToConstruct(type,
"Please use the 'new' operator, this DOM object " "Please use the 'new' operator, this DOM object "
......
...@@ -76,6 +76,9 @@ class PLATFORM_EXPORT ExceptionMessages { ...@@ -76,6 +76,9 @@ class PLATFORM_EXPORT ExceptionMessages {
static String FailedToGetIndexed(const char* type, const String& detail); static String FailedToGetIndexed(const char* type, const String& detail);
static String FailedToSetIndexed(const char* type, const String& detail); static String FailedToSetIndexed(const char* type, const String& detail);
static String FailedToDeleteIndexed(const char* type, const String& detail); static String FailedToDeleteIndexed(const char* type, const String& detail);
static String FailedToGetNamed(const char* type, const String& detail);
static String FailedToSetNamed(const char* type, const String& detail);
static String FailedToDeleteNamed(const char* type, const String& detail);
template <typename NumType> template <typename NumType>
static String FormatNumber(NumType number) { static String FormatNumber(NumType number) {
......
...@@ -212,11 +212,11 @@ String ExceptionState::AddExceptionContext(const String& message) const { ...@@ -212,11 +212,11 @@ String ExceptionState::AddExceptionContext(const String& message) const {
case kIndexedDeletionContext: case kIndexedDeletionContext:
return ExceptionMessages::FailedToDeleteIndexed(i, m); return ExceptionMessages::FailedToDeleteIndexed(i, m);
case kNamedGetterContext: case kNamedGetterContext:
break; return ExceptionMessages::FailedToGetNamed(i, m);
case kNamedSetterContext: case kNamedSetterContext:
break; return ExceptionMessages::FailedToSetNamed(i, m);
case kNamedDeletionContext: case kNamedDeletionContext:
break; return ExceptionMessages::FailedToDeleteNamed(i, m);
case kUnknownContext: case kUnknownContext:
break; break;
} }
...@@ -245,11 +245,11 @@ String ExceptionState::AddExceptionContext(const String& message) const { ...@@ -245,11 +245,11 @@ String ExceptionState::AddExceptionContext(const String& message) const {
case kIndexedDeletionContext: case kIndexedDeletionContext:
return ExceptionMessages::FailedToDeleteIndexed(i, m); return ExceptionMessages::FailedToDeleteIndexed(i, m);
case kNamedGetterContext: case kNamedGetterContext:
break; return ExceptionMessages::FailedToGetNamed(i, m);
case kNamedSetterContext: case kNamedSetterContext:
break; return ExceptionMessages::FailedToSetNamed(i, m);
case kNamedDeletionContext: case kNamedDeletionContext:
break; return ExceptionMessages::FailedToDeleteNamed(i, m);
case kUnknownContext: case kUnknownContext:
break; break;
} }
......
...@@ -24,9 +24,9 @@ PASS testSet('', 'data-') is true ...@@ -24,9 +24,9 @@ PASS testSet('', 'data-') is true
PASS testSet('à', 'data-à') is true PASS testSet('à', 'data-à') is true
PASS testSet('-foo', 'dummy') threw exception SyntaxError: '-foo' is not a valid property name.. PASS testSet('-foo', 'dummy') threw exception SyntaxError: Failed to set a named property on 'DOMStringMap': '-foo' is not a valid property name..
PASS testSet('foo ', 'dummy') threw exception InvalidCharacterError: 'data-foo ' is not a valid attribute name.. PASS testSet('foo ', 'dummy') threw exception InvalidCharacterError: Failed to set a named property on 'DOMStringMap': 'data-foo ' is not a valid attribute name..
PASS testSet('foo豈', 'dummy') threw exception InvalidCharacterError: 'data-foo豈' is not a valid attribute name.. PASS testSet('foo豈', 'dummy') threw exception InvalidCharacterError: Failed to set a named property on 'DOMStringMap': 'data-foo豈' is not a valid attribute name..
PASS testDelete('data-foo', 'foo') is true PASS testDelete('data-foo', 'foo') is true
......
...@@ -55,9 +55,9 @@ shouldBeTrue("testSet('', 'data-')"); ...@@ -55,9 +55,9 @@ shouldBeTrue("testSet('', 'data-')");
shouldBeTrue("testSet('\xE0', 'data-\xE0')"); shouldBeTrue("testSet('\xE0', 'data-\xE0')");
debug(""); debug("");
shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: \'-foo\' is not a valid property name."'); shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set a named property on \'DOMStringMap\': \'-foo\' is not a valid property name."');
shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: \'data-foo\x20\' is not a valid attribute name."'); shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: Failed to set a named property on \'DOMStringMap\': \'data-foo \' is not a valid attribute name."');
shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: \'data-foo\uF900\' is not a valid attribute name."'); shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: Failed to set a named property on \'DOMStringMap\': \'data-foo\uF900\' is not a valid attribute name."');
debug(""); debug("");
function testDelete(attr, prop) function testDelete(attr, prop)
......
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