mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1323108 - Check own flags property in RegExpPrototypeOptimizableRaw. r=h4writer
This commit is contained in:
parent
0f903d3990
commit
2ccc49f471
@ -1605,7 +1605,7 @@ js::RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto, uint8_t* resul
|
||||
}
|
||||
|
||||
JSFunction* flagsGetter;
|
||||
if (!GetGetterPure(cx, proto, NameToId(cx->names().flags), &flagsGetter))
|
||||
if (!GetOwnGetterPure(cx, proto, NameToId(cx->names().flags), &flagsGetter))
|
||||
return false;
|
||||
|
||||
if (!flagsGetter) {
|
||||
|
@ -2387,7 +2387,7 @@ js::GetPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, Value* vp)
|
||||
}
|
||||
|
||||
static inline bool
|
||||
NativeGetGetterPureInline(NativeObject* pobj, Shape* shape, JSFunction** fp)
|
||||
NativeGetGetterPureInline(Shape* shape, JSFunction** fp)
|
||||
{
|
||||
if (shape->hasGetterObject()) {
|
||||
if (shape->getterObject()->is<JSFunction>()) {
|
||||
@ -2415,8 +2415,23 @@ js::GetGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp)
|
||||
return true;
|
||||
}
|
||||
|
||||
return pobj->isNative() &&
|
||||
NativeGetGetterPureInline(&pobj->as<NativeObject>(), shape, fp);
|
||||
return pobj->isNative() && NativeGetGetterPureInline(shape, fp);
|
||||
}
|
||||
|
||||
bool
|
||||
js::GetOwnGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp)
|
||||
{
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
Shape* shape;
|
||||
if (!LookupOwnPropertyPure(cx, obj, id, &shape))
|
||||
return false;
|
||||
|
||||
if (!shape) {
|
||||
*fp = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NativeGetGetterPureInline(shape, fp);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1261,6 +1261,9 @@ GetPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, Value* vp);
|
||||
bool
|
||||
GetGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp);
|
||||
|
||||
bool
|
||||
GetOwnGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp);
|
||||
|
||||
bool
|
||||
GetOwnNativeGetterPure(JSContext* cx, JSObject* obj, jsid id, JSNative* native);
|
||||
|
||||
|
21
js/src/tests/ecma_6/RegExp/split-flags-on-obj.js
Normal file
21
js/src/tests/ecma_6/RegExp/split-flags-on-obj.js
Normal file
@ -0,0 +1,21 @@
|
||||
var BUGNUMBER = 0;
|
||||
var summary = "RegExp.prototype.split should reflect the change to Object.prototype.flags.";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
Object.defineProperty(Object.prototype, "flags", Object.getOwnPropertyDescriptor(RegExp.prototype, "flags"));
|
||||
delete RegExp.prototype.flags;
|
||||
|
||||
let re = /a/i;
|
||||
let a = re[Symbol.split]("1a2A3a4A5");
|
||||
assertDeepEq(a, ["1", "2", "3", "4", "5"]);
|
||||
|
||||
delete Object.prototype.flags;
|
||||
|
||||
Object.prototype.flags = "";
|
||||
|
||||
a = re[Symbol.split]("1a2A3a4A5");
|
||||
assertDeepEq(a, ["1", "2A3", "4A5"]);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
Loading…
Reference in New Issue
Block a user