mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 11:28:38 +00:00
Bug 1073446
- Object.preventExtensions() should return its argument with no conversion when the argument is a primitive value. r=till
This commit is contained in:
parent
b1016b8cff
commit
d0b4ed6358
@ -1034,15 +1034,19 @@ obj_isExtensible(JSContext *cx, unsigned argc, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
// ES6 draft rev27 (2014/08/24) 19.1.2.15 Object.preventExtensions(O)
|
||||
static bool
|
||||
obj_preventExtensions(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
RootedObject obj(cx);
|
||||
if (!GetFirstArgumentAsObject(cx, args, "Object.preventExtensions", &obj))
|
||||
return false;
|
||||
args.rval().set(args.get(0));
|
||||
|
||||
args.rval().setObject(*obj);
|
||||
// step 1
|
||||
if (!args.get(0).isObject())
|
||||
return true;
|
||||
|
||||
// steps 2-5
|
||||
RootedObject obj(cx, &args.get(0).toObject());
|
||||
|
||||
return JSObject::preventExtensions(cx, obj);
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ function test(stdlib, foreign) {
|
||||
}
|
||||
return f;
|
||||
};
|
||||
f = test(this, {ff: Object.preventExtensions});
|
||||
f = test(this, {ff: Object.defineProperty});
|
||||
f();
|
||||
|
@ -65,7 +65,7 @@ assertEq(caught, true);
|
||||
|
||||
var caught = false;
|
||||
try {
|
||||
callFFI(null, {ffi:Object.preventExtensions})();
|
||||
callFFI(null, {ffi:Object.defineProperty})();
|
||||
} catch (e) {
|
||||
caught = true;
|
||||
}
|
||||
|
21
js/src/tests/ecma_6/Object/preventExtensions.js
Normal file
21
js/src/tests/ecma_6/Object/preventExtensions.js
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var BUGNUMBER = 1073446;
|
||||
var summary = "Object.preventExtensions() should return its argument with no conversion when the argument is a primitive value";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
assertEq(Object.preventExtensions(), undefined);
|
||||
assertEq(Object.preventExtensions(undefined), undefined);
|
||||
assertEq(Object.preventExtensions(null), null);
|
||||
assertEq(Object.preventExtensions(1), 1);
|
||||
assertEq(Object.preventExtensions("foo"), "foo");
|
||||
assertEq(Object.preventExtensions(true), true);
|
||||
if (typeof Symbol === "function") {
|
||||
assertEq(Object.preventExtensions(Symbol.for("foo")), Symbol.for("foo"));
|
||||
}
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
Loading…
Reference in New Issue
Block a user