Fake servers failing in IE8 since version 1.5.0 #204

Closed
redking opened this Issue Nov 13, 2012 · 3 comments

Projects

None yet

4 participants

@redking

Hey,

Since upgrading from 1.4.2 to 1.5.0, tests that use fake servers are failing in Internet Explorer 8, with the exception

SCRIPT438: Object doesn't support property or method 'invoke'
sinon-1.5.0.js, Line 1137 Character 17

The exception occurs at the line I've commented below

function createProxy(func) {
     // Retain the function length:
     if (func.length) {
         return eval("(function proxy(" + vars.substring(0, func.length * 2 - 1) +
           ") { return proxy.invoke(func, this, slice.call(arguments)); })");
     }
     return function proxy() {
         return proxy.invoke(func, this, slice.call(arguments));  // -- Exception occurs here -- 
     };
}

The function is invoked by a call further up the stack to server.respond().

I'm loading sinon-1.5.0.js along with sinon-ie-1.5.0.js.

If I return to version 1.4.2, the error does not occur.

@tbiesemann

I am having the same problem when i create a stub.

The root cause is the handling of named function expressions in IE.
More details of this IE problem can be found here: http://kangax.github.com/nfe/

The following snippet will fail in IE but work in Chrome:
var f = function proxy(){
return proxy.invoke();
}
f.invoke = function(){return "hello";};
f();

This has to be fixed in sinon.

A fix could look like this:

Replace this snippet
return function proxy() {
return proxy.invoke(func, this, slice.call(arguments)); // -- Exception occurs here --
};

with
var f = function() {
return f.invoke(func, this, slice.call(arguments));
};
return f;

@mantoni
sinonjs member

I think this has already been addressed here: #193

@mroderick

The code in #193 does the same as @tbiesemann suggested. I am closing this

@mroderick mroderick closed this Aug 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment