5576ef617f
Object.hasOwn has shipped since 9.3. Also drive-by removing other removed feature flags from test262 config. Bug: chromium:1213927, v8:13220 Change-Id: I3d11298e1348adf5b26d63a23a6606a4ad22892c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3863807 Auto-Submit: Shu-yu Guo <syg@chromium.org> Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#82853}
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
// Copyright 2021 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
let object = { foo: false };
|
|
assertTrue((Object.hasOwn(object, "foo")));
|
|
|
|
let object2 = Object.create({ foo: true });
|
|
assertFalse(Object.hasOwn(object2, "foo"));
|
|
|
|
let object3 = Object.create(null);
|
|
assertFalse(Object.hasOwn(object3, "foo"));
|
|
|
|
let O = function() {
|
|
this.foo = 42;
|
|
};
|
|
let object8 = new O;
|
|
assertTrue((Object.hasOwn(object8, "foo")));
|
|
|
|
// Object is undefined or null
|
|
assertThrows(() => Object.hasOwn(undefined). TypeError);
|
|
assertThrows(() => Object.hasOwn(null). TypeError);
|
|
|
|
// Using defineProperty
|
|
let object4 = {};
|
|
Object.defineProperty(object4, "foo", {
|
|
value: 42
|
|
});
|
|
assertTrue((Object.hasOwn(object4, "foo")));
|
|
|
|
// Object.defineProperty with base
|
|
let base = {};
|
|
Object.defineProperty(base, "foo", {
|
|
value: 42,
|
|
configurable: true
|
|
});
|
|
let object5 = Object.create(base);
|
|
assertTrue((Object.hasOwn(base, "foo")));
|
|
assertFalse((Object.hasOwn(object5, "foo")));
|
|
|
|
// Prototype with getter and/or setter
|
|
let object6 = {
|
|
get foo() {}
|
|
};
|
|
let object7 = {
|
|
set foo(x) {}
|
|
};
|
|
assertTrue((Object.hasOwn(object6, "foo")));
|
|
assertTrue((Object.hasOwn(object7, "foo")));
|