diff options
| author | Daniel Luz | 2013-07-08 11:00:59 +0100 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-07-08 11:05:08 +0100 |
| commit | 7829c50f9e89e779980f6d60a397aedfc7eaec61 (patch) | |
| tree | 6985e746735be488c179e9eaf061d3d17667dc28 /test/AngularSpec.js | |
| parent | d88dc4a64f0cc1e83d0dd85ffffd254e72d23ca9 (diff) | |
| download | angular.js-7829c50f9e89e779980f6d60a397aedfc7eaec61.tar.bz2 | |
fix(angular.equals): do not match keys defined in the prototype chain
Merely testing for object[key] will give incorrect results on keys
defined in Object.prototype.
Note: IE8 is generally broken in this regard since `for...in` never returns
certain property keys even if they are defined directly on the object.
See #2141 - partially merges this PR
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 8fda7a65..bf952249 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -270,6 +270,14 @@ describe('angular', function() { expect(equals(new Date(0), 0)).toBe(false); expect(equals(0, new Date(0))).toBe(false); }); + + it('should correctly test for keys that are present on Object.prototype', function() { + // MS IE8 just doesn't work for this kind of thing, since "for ... in" doesn't return + // things like hasOwnProperty even if it is explicitly defined on the actual object! + if (msie<=8) return; + expect(equals({}, {hasOwnProperty: 1})).toBe(false); + expect(equals({}, {toString: null})).toBe(false); + }); }); describe('size', function() { |
