changeset: 229387:7f06ae718751

user:        ziyunfei <446240525@qq.com>
files:       js/src/builtin/Object.cpp js/src/tests/ecma_6/Object/isSealed.js
description:
Bug 1062860 - Object.isSealed() should return true when given primitive values as input. r=till
This commit is contained in:
Till Schneidereit 2014-09-04 21:08:33 +08:00
Родитель ea058db5ed
Коммит 99ba761309
2 изменённых файлов: 31 добавлений и 6 удалений

Просмотреть файл

@ -1094,17 +1094,21 @@ obj_seal(JSContext *cx, unsigned argc, Value *vp)
return JSObject::seal(cx, obj);
}
// ES6 draft rev27 (2014/08/24) 19.1.2.13 Object.isSealed(O)
static bool
obj_isSealed(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, args, "Object.isSealed", &obj))
return false;
bool sealed;
if (!JSObject::isSealed(cx, obj, &sealed))
return false;
// step 1
bool sealed = true;
// step 2
if (args.get(0).isObject()) {
RootedObject obj(cx, &args.get(0).toObject());
if (!JSObject::isSealed(cx, obj, &sealed))
return false;
}
args.rval().setBoolean(sealed);
return true;
}

Просмотреть файл

@ -0,0 +1,21 @@
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
var BUGNUMBER = 1062860;
var summary = "Object.isSealed() should return true when given primitive values as input";
print(BUGNUMBER + ": " + summary);
assertEq(Object.isSealed(), true);
assertEq(Object.isSealed(undefined), true);
assertEq(Object.isSealed(null), true);
assertEq(Object.isSealed(1), true);
assertEq(Object.isSealed("foo"), true);
assertEq(Object.isSealed(true), true);
if (typeof Symbol === "function") {
assertEq(Object.isSealed(Symbol()), true);
}
if (typeof reportCompare === "function")
reportCompare(true, true);