summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-2-47.js
blob: 65ecda5c3659c863d45bbbe919b0021d78fb015c (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
// Copyright (c) 2012 Ecma International.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 15.2.3.3-2-47
description: >
    Object.getOwnPropertyDescriptor - uses inherited toString method
    when 'P' is an object with an own valueOf and inherited toString
    methods
---*/

var proto = {};
var valueOfAccessed = false;
var toStringAccessed = false;

proto.toString = function() {
  toStringAccessed = true;
  return "test";
};

var Con = function() {};
Con.prototype = proto;

var child = new Con();
child.valueOf = function() {
  valueOfAccessed = true;
  return "10";
};
var obj = {
  "10": "length1",
  "test": "length2"
};
var desc = Object.getOwnPropertyDescriptor(obj, child);

assert.sameValue(desc.value, "length2", 'desc.value');
assert(toStringAccessed, 'toStringAccessed !== true');
assert.sameValue(valueOfAccessed, false, 'valueOfAccessed');

reportCompare(0, 0);