Describe the bug
it's possible to stub, but not to restore some properties in window object in IE11 causing sinon to throw a type error: TypeError: Cannot redefine non-configurable property '...'
To Reproduce
https://jsbin.com/qixexucasa/edit?js,console,output - compare behaviour in IE11 and any other browser.
"TypeError: Cannot redefine non-configurable property 'parent'
at restore (https://unpkg.com/[email protected]/pkg/sinon.js:3253:13)
at Global code (https://null.jsbin.com/runner:18:1)"
Expected behavior
In IE11 certain properties of window object are non-configurable, but it's still possible to stub them and this is quite useful in the tests. The expectable behaviour would be one of those:
configurable
attribute, is there any reason for this? In case of false
value sinon just creates problems for itself, so it's not possible to restore it. So this line should be always true
:Context:
Please confirm whether it's a bug or an expected behaviour.
Thank you for your detailed description of the issue.
Would going with the second strategy actually make this work in IE11? If so, that would be my preference.
Would you be up for contributing a pull request to make the necessary changes?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I having same problem and I found cause of this on sinon/default-behaviors.js line 258.
value: function value(fake, newVal) {
var rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
value: newVal,
enumerable: true,
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
});
return fake;
}
I don't know why it should follow original object's configurable option. I think it have to be always true because After it stubed, it can be restored or rewritten (typically sinon.restore()) regardless of original object's option.
Temporarily I fixed this problem by changing that code always return true.
Most helpful comment
I having same problem and I found cause of this on sinon/default-behaviors.js line 258.
I don't know why it should follow original object's configurable option. I think it have to be always true because After it stubed, it can be restored or rewritten (typically sinon.restore()) regardless of original object's option.
Temporarily I fixed this problem by changing that code always return true.