File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed
jerry-core/ecma/builtin-objects Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -128,11 +128,17 @@ ecma_builtin_object_object_get_prototype_of (ecma_value_t this_arg __attr_unused
128
128
{
129
129
/* 2. */
130
130
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
131
-
132
131
ecma_object_t *prototype_p = ecma_get_object_prototype (obj_p);
133
- ecma_ref_object (prototype_p);
134
132
135
- ret_value = ecma_make_normal_completion_value (ecma_make_object_value (prototype_p));
133
+ if (prototype_p)
134
+ {
135
+ ret_value = ecma_make_normal_completion_value (ecma_make_object_value (prototype_p));
136
+ ecma_ref_object (prototype_p);
137
+ }
138
+ else
139
+ {
140
+ ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_NULL);
141
+ }
136
142
}
137
143
138
144
return ret_value;
Original file line number Diff line number Diff line change @@ -128,8 +128,7 @@ try {
128
128
// Create an object with null as prototype
129
129
var obj = Object . create ( null )
130
130
assert ( typeof ( obj ) === "object" ) ;
131
- // FIXME: enable this assertion after the #208 is fixed.
132
- // assert (Object.getPrototypeOf (obj) === null);
131
+ assert ( Object . getPrototypeOf ( obj ) === null ) ;
133
132
134
133
try {
135
134
Object . create ( )
Original file line number Diff line number Diff line change @@ -35,11 +35,21 @@ try {
35
35
assert ( e instanceof TypeError ) ;
36
36
}
37
37
38
+ try {
39
+ var y = Object . getPrototypeOf ( null ) ;
40
+ assert ( false ) ;
41
+ } catch ( e ) {
42
+ assert ( e instanceof TypeError ) ;
43
+ }
44
+
38
45
var obj = { x : "foo" } ;
39
- assert ( Object . getPrototypeOf ( obj ) === Object . prototype )
46
+ assert ( Object . getPrototypeOf ( obj ) === Object . prototype ) ;
40
47
41
48
var constructor = function ( ) { } ;
42
49
constructor . prototype = obj ;
43
50
44
51
var d_obj = new constructor ( ) ;
45
52
assert ( Object . getPrototypeOf ( d_obj ) === obj ) ;
53
+
54
+ obj = Object . create ( null ) ;
55
+ assert ( Object . getPrototypeOf ( obj ) === null ) ;
You can’t perform that action at this time.
0 commit comments