Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't assume obj.__proto__ === Object in assertion helpers
Previously, we assumed that whatever object the user passed to the object assertion helpers had its prototype set to Object and would thus have things like a hasOwnProperty property. However, it turns out that this is not a valid assumption. This isn't limited to just corner cases; Node 6.x changed the behavior of its `querystring` module (which is also used by its `url` module) to explicitly set the prototype of querystring objects to `null` in order to prevent key collisions if someone sent a URL query string parameter with the same key as a property on the prototype. See nodejs/node#6055 for where this change was made. Therefore, we use Object.prototype.hasOwnProperty, which is guaranteed to always exist, and call it on the object the user passed in. We do the same for propertyIsEnumerable as applicable.
- Loading branch information