Bug 1180290 - Part 2: Handle prefix in DefinePropertyById. r=till,smaug

This commit is contained in:
Tooru Fujisawa 2016-01-05 03:21:24 +09:00
parent c2ec6eafe7
commit 6d8f59ef3f
2 changed files with 8 additions and 3 deletions

View File

@ -18,10 +18,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=882653
"'appendChild' called on an object that does not implement interface Node.",
"bogus method this object" ],
[ 'Object.getOwnPropertyDescriptor(Document.prototype, "documentElement").get.call({})',
"'documentElement' getter called on an object that does not implement interface Document.",
"'get documentElement' getter called on an object that does not implement interface Document.",
"bogus getter this object" ],
[ 'Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML").set.call({})',
"'innerHTML' setter called on an object that does not implement interface Element.",
"'set innerHTML' setter called on an object that does not implement interface Element.",
"bogus setter this object" ],
[ 'document.documentElement.appendChild(5)',
"Argument 1 of Node.appendChild is not an object.",

View File

@ -2110,8 +2110,10 @@ DefinePropertyById(JSContext* cx, HandleObject obj, HandleId id, HandleValue val
if (!(attrs & JSPROP_PROPOP_ACCESSORS) &&
getter != JS_PropertyStub && setter != JS_StrictPropertyStub)
{
RootedAtom atom(cx, JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : nullptr);
if (getter && !(attrs & JSPROP_GETTER)) {
RootedAtom atom(cx, IdToFunctionName(cx, id, "get"));
if (!atom)
return false;
JSFunction* getobj = NewNativeFunction(cx, (Native) getter, 0, atom);
if (!getobj)
return false;
@ -2125,6 +2127,9 @@ DefinePropertyById(JSContext* cx, HandleObject obj, HandleId id, HandleValue val
if (setter && !(attrs & JSPROP_SETTER)) {
// Root just the getter, since the setter is not yet a JSObject.
AutoRooterGetterSetter getRoot(cx, JSPROP_GETTER, &getter, nullptr);
RootedAtom atom(cx, IdToFunctionName(cx, id, "set"));
if (!atom)
return false;
JSFunction* setobj = NewNativeFunction(cx, (Native) setter, 1, atom);
if (!setobj)
return false;