v8/test/mjsunit/get-own-property-descriptor-non-objects.js
arv 4374941837 [es6] Object.getOwnPropertyDescriptor should wrap primitives
In ES6 Object.getOwnPropertyDescriptor should call ToObject, which
means that primitive values will return descriptors from the wrapper.

BUG=v8:3964
LOG=N
R=adamk, rossberg@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/998163004

Cr-Commit-Position: refs/heads/master@{#27569}
2015-04-01 15:45:08 +00:00

35 lines
908 B
JavaScript

// Copyright 2015 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.
assertThrows(function() {
Object.getOwnPropertyDescriptor(null, 'x');
}, TypeError);
assertThrows(function() {
Object.getOwnPropertyDescriptor(undefined, 'x');
}, TypeError);
assertEquals({
configurable: false,
enumerable: false,
value: 3,
writable: false,
}, Object.getOwnPropertyDescriptor('abc', 'length'));
assertEquals({
configurable: false,
enumerable: true,
value: 'a',
writable: false,
}, Object.getOwnPropertyDescriptor('abc', 0));
assertSame(undefined, Object.getOwnPropertyDescriptor(42, 'x'));
assertSame(undefined, Object.getOwnPropertyDescriptor(true, 'x'));
assertSame(undefined, Object.getOwnPropertyDescriptor(false, 'x'));
assertSame(undefined, Object.getOwnPropertyDescriptor(Symbol(), 'x'));