mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
837 B
36 lines
837 B
11 years ago
|
/*
|
||
|
* http://webreflection.blogspot.fi/2014/05/fixing-java-nashorn-proto.html
|
||
|
*/
|
||
|
|
||
|
/*===
|
||
|
true
|
||
|
false
|
||
|
true
|
||
|
[object Object]
|
||
|
false
|
||
|
true
|
||
|
===*/
|
||
|
|
||
|
function test() {
|
||
|
var obj;
|
||
|
|
||
|
obj = {};
|
||
|
print('__proto__' in obj);
|
||
|
print(Object.getOwnPropertyNames(obj).indexOf('__proto__') >= 0); // not own property
|
||
|
print(Object.getOwnPropertyNames(Object.prototype).indexOf('__proto__') >= 0); // inherited accessor
|
||
|
print(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__'));
|
||
|
|
||
|
obj = Object.create(null);
|
||
|
obj.__proto__ = []; // no magic __proto__, becomes own property
|
||
|
print(obj instanceof Array); // no, not inherited
|
||
|
print(Object.getOwnPropertyNames(Object.prototype).indexOf('__proto__') >= 0); // own property
|
||
|
|
||
|
// XXX: no __proto__ literals (yet)
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
test();
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|