Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 1 | // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | function getLength(a) { |
| 6 | return a.length; |
| 7 | } |
| 8 | |
| 9 | function getByteLength(a) { |
| 10 | return a.byteLength; |
| 11 | } |
| 12 | |
| 13 | function getByteOffset(a) { |
| 14 | return a.byteOffset; |
| 15 | } |
| 16 | |
| 17 | var a = new Uint8Array([1, 2, 3]); |
| 18 | getLength(a); |
| 19 | getLength(a); |
| 20 | |
| 21 | Object.defineProperty(a.__proto__, 'length', {value: 42}); |
| 22 | |
| 23 | assertEquals(42, getLength(a)); |
| 24 | assertEquals(42, a.length); |
| 25 | |
| 26 | getByteLength(a); |
| 27 | getByteLength(a); |
| 28 | |
| 29 | Object.defineProperty(a.__proto__, 'byteLength', {value: 42}); |
| 30 | |
| 31 | assertEquals(42, getByteLength(a)); |
| 32 | assertEquals(42, a.byteLength); |
| 33 | |
| 34 | getByteOffset(a); |
| 35 | getByteOffset(a); |
| 36 | |
| 37 | Object.defineProperty(a.__proto__, 'byteOffset', {value: 42}); |
| 38 | |
| 39 | assertEquals(42, getByteOffset(a)); |
| 40 | assertEquals(42, a.byteOffset); |