diff --git a/test/index.html b/test/index.html
index 613c796b3..9e44b13e3 100644
--- a/test/index.html
+++ b/test/index.html
@@ -38,15 +38,15 @@
function addBizarroMethods() {
// allow bypassing native checks
setProperty(Function.prototype, 'toString', (function() {
- function fnToString() {
- setProperty(Function.prototype, 'toString', _fnToString);
- var result = this === Set ? this.toString() : _fnToString.call(this);
+ function wrapper() {
setProperty(Function.prototype, 'toString', fnToString);
+ var result = this === Set ? this.toString() : fnToString.call(this);
+ setProperty(Function.prototype, 'toString', wrapper);
return result;
}
- var _fnToString = Function.prototype.toString;
- setProperty(Function.prototype, '_toString', _fnToString);
- return fnToString;
+ var fnToString = Function.prototype.toString;
+ setProperty(Function.prototype, '_toString', fnToString);
+ return wrapper;
}()));
// add extensions
@@ -71,6 +71,23 @@
setProperty(Object, '_keys', Object.keys);
setProperty(Object, 'keys', function() {});
+ setProperty(Object.prototype, 'hasOwnProperty', (function() {
+ function wrapper(key) {
+ if (key == '1' && this && typeof this == 'object' && this.length === 2 &&
+ hasOwnProperty.call(this, 'callee') &&
+ !propertyIsEnumerable.call(this, 'callee') &&
+ this[0] === 0 && this[1] === 0) {
+ throw new Error;
+ }
+ return hasOwnProperty.call(this, key);
+ }
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
+ propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
+
+ setProperty(Object.prototype, '_hasOwnProperty', hasOwnProperty);
+ return wrapper;
+ }()));
+
setProperty(String.prototype, '_contains', String.prototype.contains);
setProperty(String.prototype, 'contains', String.prototype._contains ? function() {} : Boolean);
@@ -118,6 +135,7 @@
}
setProperty(window, 'WinRTError', undefined);
setProperty(Function.prototype, 'toString', Function.prototype._toString);
+ setProperty(Object.prototype, 'hasOwnProperty', Object.prototype._hasOwnProperty);
document.createDocumentFragment = document._createDocumentFragment;
setProperty(document, '_createDocumentFragment', undefined);
@@ -130,6 +148,7 @@
delete Object._defineProperty;
delete Object._getPrototypeOf;
delete Object._keys;
+ delete Object.prototype._hasOwnProperty;
delete String.prototype._contains;
}
diff --git a/test/test.js b/test/test.js
index aad584e89..7a4723f75 100644
--- a/test/test.js
+++ b/test/test.js
@@ -297,15 +297,12 @@
}
// allow bypassing native checks
var _fnToString = Function.prototype.toString;
- setProperty(Function.prototype, 'toString', (function() {
- function fnToString() {
- setProperty(Function.prototype, 'toString', _fnToString);
- var result = this === Set ? this.toString() : _fnToString.call(this);
- setProperty(Function.prototype, 'toString', fnToString);
- return result;
- }
- return fnToString;
- }()));
+ setProperty(Function.prototype, 'toString', function wrapper() {
+ setProperty(Function.prototype, 'toString', _fnToString);
+ var result = this === Set ? this.toString() : _fnToString.call(this);
+ setProperty(Function.prototype, 'toString', wrapper);
+ return result;
+ });
// fake DOM
setProperty(global, 'window', {});
@@ -339,6 +336,14 @@
var _keys = Object.keys;
setProperty(Object, 'keys', function() {});
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
+ setProperty(Object.prototype, 'hasOwnProperty', function(key) {
+ if (key == '1' && _.isArguments(this) && _.isEqual(_.values(this), [0, 0])) {
+ throw new Error;
+ }
+ return _hasOwnProperty.call(this, key);
+ });
+
var _contains = String.prototype.contains;
setProperty(String.prototype, 'contains', _contains ? function() {} : Boolean);
@@ -355,6 +360,7 @@
setProperty(Object, 'defineProperty', _defineProperty);
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
setProperty(Object, 'keys', _keys);
+ setProperty(Object.prototype, 'hasOwnProperty', _hasOwnProperty);
setProperty(Function.prototype, 'toString', _fnToString);
if (_contains) {