From 4e5e7bb4c8eda1f6cb7f1cb4774eb26c15e7110a Mon Sep 17 00:00:00 2001 From: Peter Gal Date: Fri, 3 Jul 2015 17:27:01 +0200 Subject: [PATCH] Set global object's prototype The global object should have the same prototype as a simple object. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com --- .../ecma/builtin-objects/ecma-builtins.inc.h | 2 +- tests/jerry/global.js | 17 +++++++++++++++++ tests/jerry/regression-test-issue-122.js | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/jerry/global.js diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h index a2a7abca6..caef8eaa0 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h @@ -301,7 +301,7 @@ BUILTIN (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR, /* The Global object (15.1) */ BUILTIN (ECMA_BUILTIN_ID_GLOBAL, ECMA_OBJECT_TYPE_GENERAL, - ECMA_BUILTIN_ID__COUNT /* no prototype */, + ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, /* Implementation-dependent */ true, true, global) diff --git a/tests/jerry/global.js b/tests/jerry/global.js new file mode 100644 index 000000000..52303be4d --- /dev/null +++ b/tests/jerry/global.js @@ -0,0 +1,17 @@ +// Copyright 2015 Samsung Electronics Co., Ltd. +// Copyright 2015 University of Szeged. +// +// 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. + + +assert (this.hasOwnProperty !== undefined); diff --git a/tests/jerry/regression-test-issue-122.js b/tests/jerry/regression-test-issue-122.js index cec41be20..b09c4de9a 100644 --- a/tests/jerry/regression-test-issue-122.js +++ b/tests/jerry/regression-test-issue-122.js @@ -15,10 +15,11 @@ try { - print(this, []); + print({toString: function() { throw new TypeError("foo"); }}, []); assert (false); } catch (e) { assert (e instanceof TypeError); + assert (e.message === "foo"); }