What did you expect to happen?
I should be able to stub global functions via stub method under every browser:
What actually happens
Stubbing with above syntax fails under Firefox 51 with error:
Not allowed to define a non-configurable property on the WindowProxy object
My guess: Object.defineProperty on window with non-configurable property throws exception.
This is probably caused by recent changes to Window and WindowProxy:
Firefox is the first browser to implement this spec, but my understanding is that other browsers will follow at some point. This means the mentioned error is here to stay and needs to be fixed sooner or later.
Other resources discussing the WindowProxy change in depth (W3C/Mozilla):
How to reproduce
Download Firefox 51 or later (eg. from https://www.mozilla.org/en-US/firefox/developer/).
Try to run basic test with sinon.stub(object,'method')
This will fail:
But this will work fine:
var oldMyFunction = window.myFunction; // backup original function for later
window.myFunction = sinon.stub(); // overwrite function with anonymous stub
// [do tests with stub here]
window.myFunction = oldMyFunction; // restore original function
So.. we have a workaround.
It seems some kind of fix for stub(obj, method) needs to applied to work with WindowProxy.
If "real life" example is needed, this line from my pet project produces error under Firefox 51 (with stacktrace), but works fine under Firefox 49.
This is my first report here, please let me know if I can provide any additional information.