Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions jerry-core/ecma/builtin-objects/ecma-builtin-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ ecma_builtin_object_object_get_prototype_of (ecma_value_t this_arg __attr_unused
{
/* 2. */
ecma_object_t *obj_p = ecma_get_object_from_value (arg);

ecma_object_t *prototype_p = ecma_get_object_prototype (obj_p);
ecma_ref_object (prototype_p);

ret_value = ecma_make_normal_completion_value (ecma_make_object_value (prototype_p));
if (prototype_p)
{
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (prototype_p));
ecma_ref_object (prototype_p);
}
else
{
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_NULL);
}
}

return ret_value;
Expand Down
3 changes: 1 addition & 2 deletions tests/jerry/object-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ try {
// Create an object with null as prototype
var obj = Object.create(null)
assert (typeof (obj) === "object");
// FIXME: enable this assertion after the #208 is fixed.
// assert (Object.getPrototypeOf (obj) === null);
assert (Object.getPrototypeOf (obj) === null);

try {
Object.create()
Expand Down
12 changes: 11 additions & 1 deletion tests/jerry/object-getprototypeof.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ try {
assert (e instanceof TypeError);
}

try {
var y = Object.getPrototypeOf(null);
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}

var obj = { x : "foo" };
assert (Object.getPrototypeOf(obj) === Object.prototype)
assert (Object.getPrototypeOf(obj) === Object.prototype);

var constructor = function () {};
constructor.prototype = obj;

var d_obj = new constructor();
assert (Object.getPrototypeOf(d_obj) === obj);

obj = Object.create(null);
assert (Object.getPrototypeOf(obj) === null);