Not allowed to define a non-configurable property on the WindowProxy object #1195

lidel opened this Issue Nov 23, 2016 · 0 comments


None yet

1 participant

lidel commented Nov 23, 2016 edited

What did you expect to happen?

I should be able to stub global functions via stub method under every browser:

sinon.stub(window, 'myFunction')

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
Try to run basic test with sinon.stub(object,'method')

This will fail:

sinon.stub(window, 'myFunction')

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.

@lidel lidel referenced this issue in lidel/ipfs-firefox-addon Nov 23, 2016

Fix unit tests under Firefox Nightly #174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment