Bug 1313914 - ObjectDefineProperties should throw for non-callable accessors. r=arai
authorTom Schuster <evilpies@gmail.com>
Sun, 30 Oct 2016 15:57:09 +0100
changeset 320217 192f2eb705fdbaf0217cd2dfce18cc5318d3f776
parent 320216 bc0cbdabb7512afce5179229920b40af4cbf2acf
child 320218 a44d3d73a9903bc9e9a565fd7b96da30fecd782d
push id20754
push usercbook@mozilla.com
push dateMon, 31 Oct 2016 15:58:35 +0000
treeherderfx-team@b1b66b1780c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1313914
milestone52.0a1
Bug 1313914 - ObjectDefineProperties should throw for non-callable accessors. r=arai
js/src/builtin/Object.cpp
js/src/tests/ecma_5/Object/defineProperties-callable-accessor.js
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -699,17 +699,17 @@ ObjectDefineProperties(JSContext* cx, Ha
 
         // Step 5.a.
         if (!GetOwnPropertyDescriptor(cx, props, nextKey, &desc))
             return false;
 
         // Step 5.b.
         if (desc.object() && desc.enumerable()) {
             if (!GetProperty(cx, props, props, nextKey, &descObj) ||
-                !ToPropertyDescriptor(cx, descObj, false, &desc) ||
+                !ToPropertyDescriptor(cx, descObj, true, &desc) ||
                 !descriptors.append(desc) ||
                 !descriptorKeys.append(nextKey))
             {
                 return false;
             }
         }
     }
 
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_5/Object/defineProperties-callable-accessor.js
@@ -0,0 +1,19 @@
+// ObjectDefineProperties with non callable accessor throws.
+const descriptors = [
+    {get: 1}, {set: 1},
+    {get: []}, {set: []},
+    {get: {}}, {set: {}},
+    {get: new Number}, {set: new Number},
+
+    {get: 1, set: 1},
+    {get: [], set: []},
+    {get: {}, set: {}},
+    {get: new Number, set: new Number},
+];
+
+for (const descriptor of descriptors) {
+    assertThrowsInstanceOf(() => Object.create(null, {x: descriptor}), TypeError);
+    assertThrowsInstanceOf(() => Object.defineProperties({}, {x: descriptor}), TypeError);
+}
+
+reportCompare(true, true);