// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

js> load('testsrc/doctests/util.js');

js> Object.getOwnPropertyNames;
function getOwnPropertyNames() { [native code for Object.getOwnPropertyNames, arity=1] }

js> expectTypeError(function() { Object.getOwnPropertyNames() })
js> [undefined, null, true, 1, 'hello'].forEach(function(value) { 
  >   expectTypeError(function() { Object.getOwnPropertyNames(value) }) 
  > })

js> Object.getOwnPropertyNames({}).toSource();
[]
js> Object.getOwnPropertyNames({a:2}).toSource();
["a"]
js> Object.getOwnPropertyNames({a:1, b:2}).toSource();
["a", "b"]
js> Object.getOwnPropertyNames({'a.b':1, 'c d':2}).toSource();
["a.b", "c d"]

js> Object.getOwnPropertyNames([]).toSource();
["length"]
js> Object.getOwnPropertyNames(['a', 'b', 'c']).toSource();
["0", "1", "2", "length"]

js> function UserDefined() { this.a = 1; this.b = 2 };
js> var obj = new UserDefined()
js> Object.getOwnPropertyNames(obj).toSource()
["a", "b"]

js> UserDefined.prototype.c = 3;
3
js> Object.getOwnPropertyNames(obj).toSource()
["a", "b"]

js> // test properties of result are enumerable
js> for (var p in Object.getOwnPropertyNames({a:2, b:3})) print(p)
0
1

js> // test that properties of result are writable
js> var k = Object.getOwnPropertyNames({a:2, b:3});
js> k[1] = 'c'; k.toSource();
["a", "c"]

js> // test that properties of result are configurable
js> var k = Object.getOwnPropertyNames({a:2, b:3})
js> delete k[1];
true
js> k
a,
js> // TODO test that the attributes of the properties can be changed

js> var k = Object.getOwnPropertyNames({a:2, 5:6})
js> typeof k[1]
string
