Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default sandbox: useFakeXMLHttpRequest is not restored correctly #1840

Closed
ifrost opened this issue Jun 15, 2018 · 1 comment
Closed

Default sandbox: useFakeXMLHttpRequest is not restored correctly #1840

ifrost opened this issue Jun 15, 2018 · 1 comment

Comments

@ifrost
Copy link
Contributor

ifrost commented Jun 15, 2018

Describe the bug
sinon.useFakeXMLHttpRequest() replaces global XMLHttpRequest object, but it doesn't restore it when sinon.restore() is called. The problem is that sinon object overrides useFakeXMLHttpRequest method instead of using the one from Sandbox class and the fake is not added to the collection that is being restored when sinon.restore() is called.

To Reproduce

it("should restore XMLHttpRequest and ActiveXObject", function () {
    var globalXHR = global.XMLHttpRequest;
    var globalAXO = global.ActiveXObject;
    sinon.useFakeXMLHttpRequest();

    sinon.restore();

    assert.same(global.XMLHttpRequest, globalXHR);
    assert.same(global.ActiveXObject, globalAXO);
});

Expected behavior
The test above should pass.

Context (please complete the following information):

  • Library version: 6.0.0
  • Environment: OSX, node 8.10.0
@mroderick
Copy link
Member

This was fixed with #1841 and published to NPM as sinon@6.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants