Additional TypedArray tests
authorlittledan <littledan@chromium.org>
Fri, 17 Jul 2015 00:21:11 +0000 (17:21 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 17 Jul 2015 00:21:31 +0000 (00:21 +0000)
- Test that TypedArray properties cannot be set in strict mode
  Properties like %TypedArray%.prototype.length have a getter and no
  setter. This test verifies that property, which was apparently not
  true in the past or had no test ensuring throwing in this case.
- Test that TypedArray integer indexed properties (array elements)
  are not configurable

Both of these have passed for some time, but there are open bugs against
them and apparently no tests verifying that they are fixed.

BUG=v8:3048, v8:3799
LOG=N
R=adamk

Review URL: https://codereview.chromium.org/1232843005

Cr-Commit-Position: refs/heads/master@{#29717}

test/mjsunit/es6/typedarray.js

index ef7955c..7b1cc06 100644 (file)
@@ -417,6 +417,7 @@ var typedArrayConstructors = [
 
 function TestPropertyTypeChecks(constructor) {
   function CheckProperty(name) {
+    assertThrows(function() { 'use strict'; new constructor(10)[name] = 0; })
     var d = Object.getOwnPropertyDescriptor(constructor.prototype, name);
     var o = {};
     assertThrows(function() {d.get.call(o);}, TypeError);
@@ -756,3 +757,13 @@ TestArbitrary(new DataView(new ArrayBuffer(256)));
 // Test direct constructor call
 assertThrows(function() { ArrayBuffer(); }, TypeError);
 assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);
+
+function TestNonConfigurableProperties(constructor) {
+  var arr = new constructor([100])
+  assertFalse(Object.getOwnPropertyDescriptor(arr,"0").configurable)
+  assertFalse(delete arr[0])
+}
+
+for(i = 0; i < typedArrayConstructors.length; i++) {
+  TestNonConfigurableProperties(typedArrayConstructors[i]);
+}