Skip to content

Commit a885664

Browse files
authored
Builtin objects accessor properties should be configurable (#3839)
http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-standard-built-in-objects JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác [email protected]
1 parent 2058ea1 commit a885664

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.inc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
3131
/* Readonly accessor properties */
3232
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
3333
ecma_builtin_arraybuffer_prototype_bytelength_getter,
34-
ECMA_PROPERTY_FIXED)
34+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
3535

3636
#if ENABLED (JERRY_ES2015)
3737
/* ECMA-262 v6, 24.1.4.4 */

jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.inc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ ROUTINE (LIT_MAGIC_STRING_SET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT32, 2,
6262
/* ECMA-262 v6, 24.2.4.1 */
6363
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
6464
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
65-
ECMA_PROPERTY_FIXED)
65+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
6666

6767
/* ECMA-262 v6, 24.2.4.2 */
6868
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
6969
ECMA_DATAVIEW_PROTOTYPE_BYTE_LENGTH_GETTER,
70-
ECMA_PROPERTY_FIXED)
70+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
7171

7272
/* ECMA-262 v6, 24.2.4.3 */
7373
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_OFFSET_UL,
7474
ECMA_DATAVIEW_PROTOTYPE_BYTE_OFFSET_GETTER,
75-
ECMA_PROPERTY_FIXED)
75+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
7676

7777
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
7878

jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.inc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
3030
/* ES2015 22.2.3.1 */
3131
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
3232
ecma_builtin_typedarray_prototype_buffer_getter,
33-
ECMA_PROPERTY_FIXED)
33+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
3434
/* ES2015 22.2.3.2 */
3535
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
3636
ecma_builtin_typedarray_prototype_bytelength_getter,
37-
ECMA_PROPERTY_FIXED)
37+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
3838
/* ES2015 22.2.3.3 */
3939
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_OFFSET_UL,
4040
ecma_builtin_typedarray_prototype_byteoffset_getter,
41-
ECMA_PROPERTY_FIXED)
41+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
4242

4343
/* ES2015 22.2.3.17 */
4444
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_LENGTH,
4545
ecma_builtin_typedarray_prototype_length_getter,
46-
ECMA_PROPERTY_FIXED)
46+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
4747

4848
#if ENABLED (JERRY_ES2015)
4949
/* ECMA-262 v6, 23.1.3.13 */
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var test_failed = false;
16+
17+
function verifyConfigurableAccessor (obj, name, string) {
18+
let prop = Object.getOwnPropertyDescriptor (obj, name);
19+
if (prop.get && !prop.configurable) {
20+
print (string + " should be configurable, but wasn't");
21+
test_failed = true;
22+
}
23+
}
24+
25+
for (let builtin_name of Reflect.ownKeys (this)) {
26+
let builtin_obj = this[builtin_name];
27+
if (builtin_name[0] === builtin_name[0].toUpperCase () && typeof builtin_obj == "function") {
28+
for (let prop of Reflect.ownKeys (builtin_obj)) {
29+
verifyConfigurableAccessor (builtin_obj, prop, builtin_name + "." + prop.toString ());
30+
}
31+
32+
let builtin_proto = builtin_obj.prototype;
33+
if (builtin_proto) {
34+
for (let prop of Reflect.ownKeys (builtin_proto)) {
35+
verifyConfigurableAccessor (builtin_proto, prop, builtin_name + ".prototype." + prop.toString ());
36+
}
37+
}
38+
39+
builtin_proto = Reflect.getPrototypeOf (builtin_obj);
40+
if (builtin_proto !== Function.prototype) {
41+
for (let prop of Reflect.ownKeys (builtin_proto.prototype)) {
42+
verifyConfigurableAccessor (builtin_proto.prototype, prop, builtin_name + ".[[Prototype]].prototype." + prop.toString ());
43+
}
44+
}
45+
}
46+
}
47+
48+
assert (!test_failed);

0 commit comments

Comments
 (0)