Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / Set / detached-buffer-realm.js
blob5e6269b2e970430860c84ca30e86af6746afbc38
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
5 description: >
6   Throws a TypeError if key has a numeric index and object has a detached
7   buffer (honoring the Realm of the current execution context)
8 info: |
9   9.4.5.5 [[Set]] ( P, V, Receiver)
11   ...
12   2. If Type(P) is String, then
13     a. Let numericIndex be ! CanonicalNumericIndexString(P).
14     b. If numericIndex is not undefined, then
15       i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
16       ii. Return true.
17   ...
19   IntegerIndexedElementSet ( O, index, value )
21   Assert: O is an Integer-Indexed exotic object.
22   Assert: Type(index) is Number.
23   If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
24   Otherwise, let numValue be ? ToNumber(value).
25   Let buffer be O.[[ViewedArrayBuffer]].
26   If IsDetachedBuffer(buffer) is true, return false.
27   ...
28 includes: [testTypedArray.js, detachArrayBuffer.js]
29 features: [align-detached-buffer-semantics-with-web-reality, cross-realm, TypedArray]
30 ---*/
32 let other = $262.createRealm().global;
33 testWithTypedArrayConstructors(function(TA) {
34   let OtherTA = other[TA.name];
35   let sample = new OtherTA(1);
36   $DETACHBUFFER(sample.buffer);
37   sample[0] = 1;
38   assert.sameValue(sample[0], undefined, '`sample[0]` is undefined');
39 });
41 reportCompare(0, 0);