Bug 1245024 - Import test262 tests. r=efaust
authorTom Schuster <evilpies@gmail.com>
Thu, 09 Jun 2016 20:28:47 +0200
changeset 301388 06a54c686fc9
parent 301387 5238e71b3635
child 301389 6fb515b4a1ba
push id30333
push usercbook@mozilla.com
push dateFri, 10 Jun 2016 13:39:58 +0000
treeherdermozilla-central@52679ce4756c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1245024
milestone50.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 1245024 - Import test262 tests. r=efaust
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/duplicate-keys.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/exception-not-object-coercible.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-length.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-name.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/inherited-properties-omitted.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/normal-object.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/observable-operations.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-booleans.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-numbers.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-strings.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-symbols.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/shell.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/symbols-included.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/tamper-with-global-object.js
js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/tamper-with-object-keys.js
js/src/tests/test262/built-ins/Object/shell.js
js/src/tests/test262/built-ins/shell.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/duplicate-keys.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors on a proxy with duplicate ownKeys should work
+esid: pending
+author: Jordan Harband
+features: [Proxy]
+---*/
+
+var i = 0;
+var descriptors = [
+  { enumerable: false, value: "A1", writable: true, configurable: true },
+  { enumerable: true, value: "A2", writable: true, configurable: true }
+];
+var log = '';
+var proxy = new Proxy({}, {
+  ownKeys() {
+    log += 'ownKeys|';
+    return ['DUPLICATE', 'DUPLICATE', 'DUPLICATE'];
+  },
+  getOwnPropertyDescriptor(t, name) {
+    log += 'getOwnPropertyDescriptor:' + name + '|';
+    return descriptors[i++];
+  }
+});
+
+var result = Object.getOwnPropertyDescriptors(proxy);
+assert.sameValue(result.hasOwnProperty('DUPLICATE'), true);
+assert.sameValue(result.DUPLICATE, undefined);
+assert.sameValue(log, 'ownKeys|getOwnPropertyDescriptor:DUPLICATE|getOwnPropertyDescriptor:DUPLICATE|getOwnPropertyDescriptor:DUPLICATE|');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/exception-not-object-coercible.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors should fail if given a null or undefined value
+esid: pending
+author: Jordan Harband
+---*/
+
+assert.throws(TypeError, function () {
+    Object.getOwnPropertyDescriptors(null);
+});
+
+assert.throws(TypeError, function () {
+    Object.getOwnPropertyDescriptors(undefined);
+});
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-length.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors should have length 1
+esid: pending
+author: Jordan Harband
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Object.getOwnPropertyDescriptors.length, 1, 'Expected Object.getOwnPropertyDescriptors.length to be 1');
+
+var desc = Object.getOwnPropertyDescriptor(Object.getOwnPropertyDescriptors, 'length');
+assertEq(desc.enumerable, false);
+assertEq(desc.writable, false);
+assertEq(desc.configurable, true);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-name.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors should have name property with value 'getOwnPropertyDescriptors'
+esid: pending
+author: Jordan Harband
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+    Object.getOwnPropertyDescriptors.name,
+    'getOwnPropertyDescriptors',
+    'Expected Object.getOwnPropertyDescriptors.name to be "getOwnPropertyDescriptors"'
+);
+
+var desc = Object.getOwnPropertyDescriptor(Object.getOwnPropertyDescriptors, 'name');
+assertEq(desc.enumerable, false);
+assertEq(desc.writable, false);
+assertEq(desc.configurable, true);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js
@@ -0,0 +1,14 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors should be writable, non-enumerable, and configurable
+esid: pending
+author: Jordan Harband
+includes: [propertyHelper.js]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(Object, 'getOwnPropertyDescriptors');
+assertEq(desc.enumerable, false);
+assertEq(desc.writable, true);
+assertEq(desc.configurable, true);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/inherited-properties-omitted.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors does not see inherited properties.
+esid: pending
+author: Jordan Harband
+---*/
+
+var F = function () {};
+F.prototype.a = {};
+F.prototype.b = {};
+
+var f = new F();
+var bValue = {};
+f.b = bValue; // shadow the prototype
+Object.defineProperty(f, 'c', {
+  enumerable: false,
+  configurable: true,
+  writable: false,
+  value: {}
+}); // solely an own property
+
+var result = Object.getOwnPropertyDescriptors(f);
+
+assert.sameValue(!!result.b, true, 'b has a descriptor');
+assert.sameValue(!!result.c, true, 'c has a descriptor');
+
+assert.sameValue(result.b.enumerable, true, 'b is enumerable');
+assert.sameValue(result.b.configurable, true, 'b is configurable');
+assert.sameValue(result.b.writable, true, 'b is writable');
+assert.sameValue(result.b.value, bValue, 'b’s value is `bValue`');
+
+assert.sameValue(result.c.enumerable, false, 'c is enumerable');
+assert.sameValue(result.c.configurable, true, 'c is configurable');
+assert.sameValue(result.c.writable, false, 'c is writable');
+assert.sameValue(result.c.value, f.c, 'c’s value is `f.c`');
+
+assert.sameValue(
+  Object.keys(result).length,
+  2,
+  'result has same number of own property names as f'
+);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/normal-object.js
@@ -0,0 +1,13 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors should produce a normal object inheriting from Object.prototype
+esid: pending
+author: Jordan Harband
+---*/
+
+assert.sameValue(
+  Object.getPrototypeOf(Object.getOwnPropertyDescriptors({})),
+  Object.prototype
+);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/observable-operations.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors should perform observable operations in the correct order
+esid: pending
+author: Jordan Harband
+features: [Proxy]
+includes: [proxyTrapsHelper.js]
+---*/
+
+var log = "";
+var object = { a: 0, b: 0, c: 0 };
+var handler = {
+  getOwnPropertyDescriptor: function (target, propertyKey) {
+    assert.sameValue(target, object, "getOwnPropertyDescriptor");
+    log += "|getOwnPropertyDescriptor:" + propertyKey;
+    return Object.getOwnPropertyDescriptor(target, propertyKey);
+  },
+  ownKeys: function (target) {
+    assert.sameValue(target, object, "ownKeys");
+    log += "|ownKeys";
+    return Object.getOwnPropertyNames(target);
+  }
+};
+var check = {
+  get: function (target, propertyKey, receiver) {
+    assertEq(propertyKey in target, true, "handler check: " + propertyKey);
+    return target[propertyKey];
+  }
+};
+var proxy = new Proxy(object, new Proxy(handler, check));
+var result = Object.getOwnPropertyDescriptors(proxy);
+assert.sameValue(log, "|ownKeys|getOwnPropertyDescriptor:a|getOwnPropertyDescriptor:b|getOwnPropertyDescriptor:c", 'log');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-booleans.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors accepts boolean primitives.
+esid: pending
+author: Jordan Harband
+---*/
+
+var trueResult = Object.getOwnPropertyDescriptors(true);
+
+assert.sameValue(Object.keys(trueResult).length, 0, 'trueResult has 0 items');
+
+var falseResult = Object.getOwnPropertyDescriptors(false);
+
+assert.sameValue(Object.keys(falseResult).length, 0, 'falseResult has 0 items');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-numbers.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors accepts number primitives.
+esid: pending
+author: Jordan Harband
+---*/
+
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors(0)).length, 0, '0 has zero descriptors');
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors(-0)).length, 0, '-0 has zero descriptors');
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors(Infinity)).length, 0, 'Infinity has zero descriptors');
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors(-Infinity)).length, 0, '-Infinity has zero descriptors');
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors(NaN)).length, 0, 'NaN has zero descriptors');
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors(Math.PI)).length, 0, 'Math.PI has zero descriptors');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-strings.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors accepts string primitives.
+esid: pending
+author: Jordan Harband
+---*/
+
+var result = Object.getOwnPropertyDescriptors('abc');
+
+assert.sameValue(Object.keys(result).length, 4, 'string has 4 descriptors');
+
+assert.sameValue(result.length.configurable, false, 'length is not configurable');
+assert.sameValue(result.length.enumerable, false, 'length is not enumerable');
+assert.sameValue(result.length.writable, false, 'length is not writable');
+assert.sameValue(result.length.value, 3, 'length is 3');
+
+assert.sameValue(result[0].configurable, false, 'index 0 is not configurable');
+assert.sameValue(result[0].enumerable, true, 'index 0 is enumerable');
+assert.sameValue(result[0].writable, false, 'index 0 is not writable');
+assert.sameValue(result[0].value, 'a', 'index 0 is "a"');
+
+assert.sameValue(result[1].configurable, false, 'index 1 is not configurable');
+assert.sameValue(result[1].enumerable, true, 'index 1 is enumerable');
+assert.sameValue(result[1].writable, false, 'index 1 is not writable');
+assert.sameValue(result[1].value, 'b', 'index 1 is "b"');
+
+assert.sameValue(result[2].configurable, false, 'index 2 is not configurable');
+assert.sameValue(result[2].enumerable, true, 'index 2 is enumerable');
+assert.sameValue(result[2].writable, false, 'index 2 is not writable');
+assert.sameValue(result[2].value, 'c', 'index 2 is "c"');
+
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/primitive-symbols.js
@@ -0,0 +1,13 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors accepts Symbol primitives.
+esid: pending
+author: Jordan Harband
+features: [Symbol]
+---*/
+
+var result = Object.getOwnPropertyDescriptors(Symbol());
+
+assert.sameValue(Object.keys(result).length, 0, 'symbol primitive has no descriptors');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/shell.js
@@ -0,0 +1,18 @@
+var assert = {
+    sameValue: assertEq,
+    throws(ctor, f) {
+      var fullmsg;
+      try {
+        f();
+      } catch (exc) {
+        if (exc instanceof ctor)
+          return;
+        fullmsg = "Assertion failed: expected exception " + ctor.name + ", got " + exc;
+      }
+      if (fullmsg === undefined)
+        fullmsg = "Assertion failed: expected exception " + ctor.name + ", no exception thrown";
+      if (msg !== undefined)
+        fullmsg += " - " + msg;
+      throw new Error(fullmsg);
+    }
+}
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/symbols-included.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Object.getOwnPropertyDescriptors includes Symbol keys.
+esid: pending
+author: Jordan Harband
+features: [Symbol]
+---*/
+
+var value = {};
+var enumSym = Symbol('enum');
+var nonEnumSym = Symbol('nonenum');
+var symValue = Symbol('value');
+
+var obj = { key: symValue };
+obj[enumSym] = value;
+Object.defineProperty(obj, nonEnumSym, { writable: true, enumerable: false, configurable: true, value: value });
+
+var result = Object.getOwnPropertyDescriptors(obj);
+
+assert.sameValue(Object.keys(result).length, 1, 'obj has 1 string-keyed descriptor');
+assert.sameValue(Object.getOwnPropertySymbols(result).length, 2, 'obj has 2 symbol-keyed descriptors');
+
+assert.sameValue(result.key.configurable, true, 'result.key is configurable');
+assert.sameValue(result.key.enumerable, true, 'result.key is enumerable');
+assert.sameValue(result.key.writable, true, 'result.key is writable');
+assert.sameValue(result.key.value, symValue, 'result.key has value symValue');
+
+assert.sameValue(result[enumSym].configurable, true, 'result[enumSym] is configurable');
+assert.sameValue(result[enumSym].enumerable, true, 'result[enumSym] is enumerable');
+assert.sameValue(result[enumSym].writable, true, 'result[enumSym] is writable');
+assert.sameValue(result[enumSym].value, value, 'result[enumSym] has value `value`');
+
+assert.sameValue(result[nonEnumSym].configurable, true, 'result[nonEnumSym] is configurable');
+assert.sameValue(result[nonEnumSym].enumerable, false, 'result[nonEnumSym] is not enumerable');
+assert.sameValue(result[nonEnumSym].writable, true, 'result[nonEnumSym] is writable');
+assert.sameValue(result[nonEnumSym].value, value, 'result[nonEnumSym] has value `value`');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/tamper-with-global-object.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+    Object.getOwnPropertyDescriptors should not have its behavior impacted by modifications to the global property Object
+esid: pending
+author: Jordan Harband
+---*/
+
+function fakeObject() {
+    $ERROR('The overriden version of Object was called!');
+}
+fakeObject.getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
+fakeObject.keys = Object.keys;
+
+var global = this;
+global.Object = fakeObject;
+
+assert.sameValue(Object, fakeObject, 'Sanity check failed: could not modify the global Object');
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors('a')).length, 2, 'Expected string primitive to have 2 descriptors');
new file mode 100644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/tamper-with-object-keys.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+    Object.getOwnPropertyDescriptors should not have its behavior impacted by modifications to Object.getOwnPropertyDescriptor
+esid: pending
+author: Jordan Harband
+---*/
+
+function fakeObjectGetOwnPropertyDescriptor() {
+    $ERROR('The overriden version of Object.getOwnPropertyDescriptor was called!');
+}
+Object.getOwnPropertyDescriptor = fakeObjectGetOwnPropertyDescriptor;
+
+assert.sameValue(
+  Object.getOwnPropertyDescriptor,
+  fakeObjectGetOwnPropertyDescriptor,
+  'Sanity check failed: could not modify the global Object.getOwnPropertyDescriptor'
+);
+
+assert.sameValue(Object.keys(Object.getOwnPropertyDescriptors({ a: 1 })).length, 1, 'Expected object with 1 key to have 1 descriptor');
new file mode 100644
new file mode 100644