Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 23440058: Improve generated TypeError exception messages in bindings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/scripts/code_generator_v8.pm
diff --git a/Source/bindings/scripts/code_generator_v8.pm b/Source/bindings/scripts/code_generator_v8.pm
index 742e03f984c3533da3aa2966503938d446cfed7d..c0d20772ab675ec084ca96e463e542e00d982949 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -2642,7 +2642,7 @@ sub GenerateConstructorCallback
$code .= " TRACE_EVENT_SCOPED_SAMPLING_STATE(\"Blink\", \"DOMConstructor\");\n";
$code .= GenerateFeatureObservation($interface->extendedAttributes->{"MeasureAs"});
$code .= GenerateDeprecationNotification($interface->extendedAttributes->{"DeprecateAs"});
- $code .= GenerateConstructorHeader();
+ $code .= GenerateConstructorHeader($implClassName);
if (HasCustomConstructor($interface)) {
$code .= " ${v8ClassName}::constructorCustom(args);\n";
} else {
@@ -2825,7 +2825,7 @@ static void ${v8ClassName}ConstructorCallback(const v8::FunctionCallbackInfo<v8:
END
$code .= $maybeObserveFeature if $maybeObserveFeature;
$code .= $maybeDeprecateFeature if $maybeDeprecateFeature;
- $code .= GenerateConstructorHeader();
+ $code .= GenerateConstructorHeader($implClassName);
AddToImplIncludes("V8Document.h");
$code .= <<END;
Document* document = currentDocument();
@@ -2914,10 +2914,13 @@ END
sub GenerateConstructorHeader
{
+ my $name = shift;
+
+ AddToImplIncludes("bindings/v8/ExceptionMessages.h");
AddToImplIncludes("bindings/v8/V8ObjectConstructor.h");
my $content = <<END;
if (!args.IsConstructCall()) {
- throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
+ throwTypeError(ExceptionMessages::failedToConstruct("$name", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), args.GetIsolate());
return;
}
« no previous file with comments | « LayoutTests/fast/mediastream/constructors-expected.txt ('k') | Source/bindings/tests/results/V8Float64Array.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698