OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Test that the methods for different TypedArray types have the same | 5 // Test that the methods for different TypedArray types have the same |
6 // identity. | 6 // identity. |
7 | 7 |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 let typedArrayConstructors = [ | 10 let typedArrayConstructors = [ |
(...skipping 10 matching lines...) Expand all Loading... |
21 let TypedArray = Uint8Array.__proto__; | 21 let TypedArray = Uint8Array.__proto__; |
22 let TypedArrayPrototype = TypedArray.prototype; | 22 let TypedArrayPrototype = TypedArray.prototype; |
23 | 23 |
24 assertEquals(TypedArray.__proto__, Function.prototype); | 24 assertEquals(TypedArray.__proto__, Function.prototype); |
25 assertEquals(TypedArrayPrototype.__proto__, Object.prototype); | 25 assertEquals(TypedArrayPrototype.__proto__, Object.prototype); |
26 | 26 |
27 // There are extra own class properties due to it simply being a function | 27 // There are extra own class properties due to it simply being a function |
28 let classProperties = new Set([ | 28 let classProperties = new Set([ |
29 "length", "name", "arguments", "caller", "prototype", "BYTES_PER_ELEMENT" | 29 "length", "name", "arguments", "caller", "prototype", "BYTES_PER_ELEMENT" |
30 ]); | 30 ]); |
31 let instanceProperties = new Set(["BYTES_PER_ELEMENT", "constructor", "prototype
"]); | 31 let instanceProperties = new Set([ |
| 32 "BYTES_PER_ELEMENT", "constructor", "prototype", |
| 33 // length is also an instance property as a temporary workaround to |
| 34 // BUG(chromium:579905). TODO(littledan): remove the workaround |
| 35 "length" |
| 36 ]); |
32 | 37 |
33 function functionProperties(object) { | 38 function functionProperties(object) { |
34 return Object.getOwnPropertyNames(object).filter(function(name) { | 39 return Object.getOwnPropertyNames(object).filter(function(name) { |
35 return typeof Object.getOwnPropertyDescriptor(object, name).value | 40 return typeof Object.getOwnPropertyDescriptor(object, name).value |
36 == "function" | 41 == "function" && name != 'constructor'; |
37 && name != 'constructor' && name != 'subarray'; | |
38 }); | 42 }); |
39 } | 43 } |
40 | 44 |
41 let typedArrayMethods = functionProperties(Uint8Array.prototype); | 45 let typedArrayMethods = functionProperties(Uint8Array.prototype); |
42 let typedArrayClassMethods = functionProperties(Uint8Array); | 46 let typedArrayClassMethods = functionProperties(Uint8Array); |
43 | 47 |
44 for (let constructor of typedArrayConstructors) { | 48 for (let constructor of typedArrayConstructors) { |
45 for (let property of Object.getOwnPropertyNames(constructor.prototype)) { | 49 for (let property of Object.getOwnPropertyNames(constructor.prototype)) { |
46 assertTrue(instanceProperties.has(property), property); | 50 assertTrue(instanceProperties.has(property), property); |
47 } | 51 } |
(...skipping 13 matching lines...) Expand all Loading... |
61 assertFalse(desc.writable); | 65 assertFalse(desc.writable); |
62 assertFalse(desc.configurable); | 66 assertFalse(desc.configurable); |
63 assertFalse(desc.enumerable); | 67 assertFalse(desc.enumerable); |
64 | 68 |
65 for (let constructor of typedArrayConstructors) { | 69 for (let constructor of typedArrayConstructors) { |
66 let desc = Object.getOwnPropertyDescriptor(constructor, "prototype"); | 70 let desc = Object.getOwnPropertyDescriptor(constructor, "prototype"); |
67 assertFalse(desc.writable); | 71 assertFalse(desc.writable); |
68 assertFalse(desc.configurable); | 72 assertFalse(desc.configurable); |
69 assertFalse(desc.enumerable); | 73 assertFalse(desc.enumerable); |
70 } | 74 } |
OLD | NEW |