mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 596351 - Proxies should throw TypeErrors for assignments to read-only properties in ES5 strict mode. r=luke
This commit is contained in:
parent
7aa891a8c8
commit
ab0445c528
5
js/src/jit-test/tests/basic/bug596351-1.js
Normal file
5
js/src/jit-test/tests/basic/bug596351-1.js
Normal file
@ -0,0 +1,5 @@
|
||||
// |jit-test| error: TypeError
|
||||
"use strict"
|
||||
var g = newGlobal('new-compartment');
|
||||
g.eval("foo = {}; Object.defineProperty(foo, 'a', {value: 2, writable: false});");
|
||||
g.foo.a = 3;
|
7
js/src/jit-test/tests/basic/bug596351-2.js
Normal file
7
js/src/jit-test/tests/basic/bug596351-2.js
Normal file
@ -0,0 +1,7 @@
|
||||
// |jit-test| error: TypeError
|
||||
|
||||
"use strict"
|
||||
var g = newGlobal('new-compartment');
|
||||
|
||||
g.eval("bar = {}; Object.freeze(bar);");
|
||||
g.bar.a = 4;
|
@ -182,8 +182,18 @@ ProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, b
|
||||
return false;
|
||||
/* The control-flow here differs from ::get() because of the fall-through case below. */
|
||||
if (desc.obj) {
|
||||
if (desc.attrs & JSPROP_READONLY)
|
||||
// Check for read-only properties.
|
||||
if (desc.attrs & JSPROP_READONLY) {
|
||||
if (strict) {
|
||||
JSAutoByteString bytes(cx, JSID_TO_STRING(id));
|
||||
if (!bytes)
|
||||
return false;
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_CANT_REDEFINE_PROP, bytes.ptr());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!desc.setter) {
|
||||
// Be wary of the odd explicit undefined setter case possible through
|
||||
// Object.defineProperty.
|
||||
@ -208,8 +218,18 @@ ProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, b
|
||||
if (!getPropertyDescriptor(cx, proxy, id, true, &desc))
|
||||
return false;
|
||||
if (desc.obj) {
|
||||
if (desc.attrs & JSPROP_READONLY)
|
||||
// Check for read-only properties.
|
||||
if (desc.attrs & JSPROP_READONLY) {
|
||||
if (strict) {
|
||||
JSAutoByteString bytes(cx, JSID_TO_STRING(id));
|
||||
if (!bytes)
|
||||
return false;
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_CANT_REDEFINE_PROP, bytes.ptr());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!desc.setter) {
|
||||
// Be wary of the odd explicit undefined setter case possible through
|
||||
// Object.defineProperty.
|
||||
|
@ -230,8 +230,7 @@ bool
|
||||
Wrapper::set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, bool strict,
|
||||
Value *vp)
|
||||
{
|
||||
// FIXME (bug 596351): Need deal with strict mode.
|
||||
SET(wrappedObject(wrapper)->setGeneric(cx, id, vp, false));
|
||||
SET(wrappedObject(wrapper)->setGeneric(cx, id, vp, strict));
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user