Skip to content

Commit

Permalink
Fix the point and add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
iseki-masaya committed Sep 26, 2014
1 parent b6bdb42 commit a96c523
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions js/builtins/Object.prototype.hasOwnProperty-prototype-chain.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,34 @@
<meta charset="utf-8">
<title>Object.prototype.hasOwnProperty: Check prototype chain</title>
<link rel="author" title="Masaya Iseki" href="mailto:[email protected]">
<link rel="help" href="http://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.5">
<link rel="help" href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.hasownproperty">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
test(function() {
var obj = new Object();
[{}, []].forEach(function(that) {
that.prop = 'exists';
assert_true(that.hasOwnProperty('prop'));
assert_true('hasOwnProperty' in that);
assert_false(that.hasOwnProperty('hasOwnProperty'));
});
});

obj.prop = 'exists';
assert_true(Object.hasOwnProperty.call(obj, 'prop'));
assert_true('hasOwnProperty' in obj);
assert_false(Object.hasOwnProperty.call(obj, 'hasOwnProperty'));
test(function() {
['foo', 42].forEach(function(that) {
assert_false(that.hasOwnProperty('hasOwnProperty'));
});
});

test(function() {
[null, undefined].forEach(function(that) {
try {
that.hasOwnProperty('hasOwnProperty');
}
catch(err) {
assert_equals('TypeError', err.name);
}
});
});
</script>

Expand Down

0 comments on commit a96c523

Please sign in to comment.