Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArrayConstructors / internals / HasProperty / BigInt / abrupt-from-ordinary-has-parent-hasproperty.js
blobd63f2757b208662e184e863a9bcaad15cc6cb5eb
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-hasproperty-p
5 description: Return abrupt from OrdinaryHasProperty parent's [[HasProperty]]
6 info: |
7   9.4.5.2 [[HasProperty]](P)
9   ...
10   3. If Type(P) is String, then
11     a. Let numericIndex be ! CanonicalNumericIndexString(P).
12     b. If numericIndex is not undefined, then
13       i. Let buffer be O.[[ViewedArrayBuffer]].
14       ii. If IsDetachedBuffer(buffer) is true, return false.
15   ...
17   9.1.7.1 OrdinaryHasProperty (O, P)
19   ...
20   2. Let hasOwn be ? O.[[GetOwnProperty]](P).
21   3. If hasOwn is not undefined, return true.
22   4. Let parent be ? O.[[GetPrototypeOf]]().
23   5. If parent is not null, then
24     a. Return ? parent.[[HasProperty]](P).
25   6. Return false.
26 includes: [testBigIntTypedArray.js]
27 features: [align-detached-buffer-semantics-with-web-reality, BigInt, Reflect, Proxy, TypedArray]
28 ---*/
30 var handler = {
31   has: function() {
32     throw new Test262Error();
33   }
36 var proxy = new Proxy(TypedArray.prototype, handler);
38 testWithBigIntTypedArrayConstructors(function(TA) {
39   var sample = new TA(1);
41   Object.setPrototypeOf(sample, proxy);
43   assert.sameValue(
44     Reflect.has(sample, 0), true,
45     'Reflect.has(sample, 0) must return true'
46   );
47   assert.sameValue(
48     Reflect.has(sample, 1), false,
49     'Reflect.has(sample, 1) must return false'
50   );
52   assert.throws(Test262Error, function() {
53     Reflect.has(sample, "foo");
54   });
56   Object.defineProperty(sample, "foo", { value: 42 });
58   assert.sameValue(
59     Reflect.has(sample, "foo"),
60     true,
61     'Reflect.has(sample, "foo") must return true'
62   );
63 });
65 reportCompare(0, 0);