Fix prototype of NativeError objects (#3716)

Internal property [[Prototype]] of EvalError, RangeError, ReferenceError,
SyntaxError, TypeError and URIError should be Error.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
This commit is contained in:
Rafal Walczyna
2020-05-07 08:58:42 +02:00
committed by GitHub
parent 5af751263b
commit 99859fb221
2 changed files with 33 additions and 6 deletions
@@ -225,6 +225,12 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REGEXP,
regexp)
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
#if ENABLED (JERRY_ES2015)
#define ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID ECMA_BUILTIN_ID_ERROR
#else /* !ENABLED (JERRY_ES2015) */
#define ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE
#endif /* ENABLED (JERRY_ES2015 */
/* The Error object (15.11.1) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
@@ -250,7 +256,7 @@ BUILTIN (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
/* The EvalError object (15.11.6.1) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_EVAL_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID,
true,
eval_error)
@@ -264,7 +270,7 @@ BUILTIN (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE,
/* The RangeError object (15.11.6.2) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_RANGE_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID,
true,
range_error)
@@ -278,7 +284,7 @@ BUILTIN (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE,
/* The ReferenceError object (15.11.6.3) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REFERENCE_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID,
true,
reference_error)
@@ -292,7 +298,7 @@ BUILTIN (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE,
/* The SyntaxError object (15.11.6.4) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_SYNTAX_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID,
true,
syntax_error)
@@ -306,7 +312,7 @@ BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE,
/* The TypeError object (15.11.6.5) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_TYPE_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID,
true,
type_error)
@@ -320,7 +326,7 @@ BUILTIN (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE,
/* The URIError object (15.11.6.6) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_URI_ERROR,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_BUILTIN_NATIVE_ERROR_PROTOTYPE_ID,
true,
uri_error)
#endif /* ENABLED (JERRY_BUILTIN_ERRORS) */
+21
View File
@@ -0,0 +1,21 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* Prototype of NativeErrors should be Error */
assert(Object.getPrototypeOf(EvalError) === Error);
assert(Object.getPrototypeOf(RangeError) === Error);
assert(Object.getPrototypeOf(ReferenceError) === Error);
assert(Object.getPrototypeOf(SyntaxError) === Error);
assert(Object.getPrototypeOf(TypeError) === Error);
assert(Object.getPrototypeOf(URIError) === Error);