Fix Function.prototype.toString mock in test/ to avoid errors in Firefox.

This commit is contained in:
John-David Dalton
2014-01-23 00:30:59 -08:00
parent 130695fcb3
commit 62e0db7c9b
2 changed files with 25 additions and 12 deletions

View File

@@ -52,11 +52,18 @@
Function.prototype._method = function() {};
// allow bypassing native checks
var _toString = Function.prototype.toString;
setProperty(Function.prototype, '_toString', _toString);
setProperty(Function.prototype, 'toString', function() {
return this === Set ? this.toString() : _toString.call(this);
});
var _fnToString = Function.prototype.toString;
setProperty(Function.prototype, '_toString', _fnToString);
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;
}()));
// set bad shims
setProperty(Array, '_isArray', Array.isArray);
@@ -198,7 +205,7 @@
var reBasename = /[\w.-]+$/,
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
modulePath = ui.buildPath.replace(/\.js$/, ''),
locationPath = modulePath.replace(reBasename, ''),
locationPath = modulePath.replace(reBasename, '').replace(/\/$/, ''),
moduleMain = modulePath.match(reBasename)[0],
uid = +new Date;
@@ -227,7 +234,7 @@
},
{
'name': 'test',
'location': basePath + '/test',
'location': basePath + 'test',
'main': 'test',
'config': {
// work around no global being exported

View File

@@ -272,10 +272,16 @@
});
// allow bypassing native checks
var _toString = Function.prototype.toString;
setProperty(Function.prototype, 'toString', function() {
return this === Set ? this.toString() : _toString.call(this);
});
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;
}()));
// add extensions
Function.prototype._method = function() {};
@@ -325,7 +331,7 @@
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
setProperty(Object, 'keys', _keys);
setProperty(Function.prototype, 'toString', _toString);
setProperty(Function.prototype, 'toString', _fnToString);
_.forOwn({
'contains': _contains,