Bug 1180290 - Part 2: Handle prefix in DefinePropertyById. r=till,smaug
authorTooru Fujisawa <arai_a@mac.com>
Tue, 05 Jan 2016 03:21:24 +0900
changeset 278810 44725d3301db
parent 278809 b51771070a89
child 278811 dd562b7c8512
push id29860
push usercbook@mozilla.com
push dateThu, 07 Jan 2016 10:51:20 +0000
treeherdermozilla-central@e0bcd16e1d4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill, smaug
bugs1180290
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1180290 - Part 2: Handle prefix in DefinePropertyById. r=till,smaug
dom/bindings/test/test_exception_messages.html
js/src/jsapi.cpp
--- a/dom/bindings/test/test_exception_messages.html
+++ b/dom/bindings/test/test_exception_messages.html
@@ -13,20 +13,20 @@ https://bugzilla.mozilla.org/show_bug.cg
   /** Test for Bug 882653 **/
   // Each test is a string to eval, the expected exception message, and the
   // test description.
   var tests = [
       [ 'document.documentElement.appendChild.call({}, new Image())',
         "'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.",
         "bogus interface argument" ],
       [ 'document.documentElement.appendChild(null)',
         "Argument 1 of Node.appendChild is not an object.",
         "null interface argument" ],
       [ 'document.createTreeWalker(document).currentNode = 5',
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2105,31 +2105,36 @@ DefinePropertyById(JSContext* cx, Handle
     // If !(attrs & JSPROP_PROPOP_ACCESSORS), then either getter/setter are both
     // possibly-null JSNatives (or possibly-null JSFunction* if JSPROP_GETTER or
     // JSPROP_SETTER is appropriately set), or both are the well-known property
     // stubs.  The subsequent block must handle only the first of these cases,
     // so carefully exclude the latter case.
     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;
 
             if (get.info)
                 getobj->setJitInfo(get.info);
 
             getter = JS_DATA_TO_FUNC_PTR(GetterOp, getobj);
             attrs |= JSPROP_GETTER;
         }
         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;
 
             if (set.info)
                 setobj->setJitInfo(set.info);
 
             setter = JS_DATA_TO_FUNC_PTR(SetterOp, setobj);