summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/DataView/instance-extensibility.js
blob: 5c6f0b9486985ab728d073ea0cabf525f88ecc1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-dataview-buffer-byteoffset-bytelength
description: >
  The new instance is extensible
info: |
  24.2.2.1 DataView (buffer, byteOffset, byteLength )

  ...
  12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
  « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
  ...
  17. Return O.

  9.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ ,
  internalSlotsList ] )

  ...
  3. Return ObjectCreate(proto, internalSlotsList).

  9.1.12 ObjectCreate (proto [ , internalSlotsList ])

  ...
  5. Set the [[Extensible]] internal slot of obj to true.
  ...
includes: [propertyHelper.js]
---*/

var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);

assert(Object.isExtensible(sample));

Object.defineProperty(sample, 'baz', {});
assert(sample.hasOwnProperty('baz'), 'confirms extensibility adding a new property');

Object.defineProperty(sample, 'foo', {
  value: 'bar',
  writable: true,
  configurable: true,
  enumerable: false,
});

verifyProperty(sample, 'foo', {
  value: 'bar',
  writable: true,
  configurable: true,
  enumerable: false,
});

reportCompare(0, 0);