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

Polyfill Object.setPrototypeOf in tests on old Node.js versions #1932

Closed
wants to merge 5 commits into from

Conversation

goto-bus-stop
Copy link
Member

The buffer shim needs setPrototypeOf since feross/buffer#238. buffer's official support targets had it. Node 0.8/0.10 incidentally had the other things it needs, but not this.

@@ -3,6 +3,7 @@ var test = require('tap').test;
var vm = require('vm');

if (!ArrayBuffer.isView) ArrayBuffer.isView = function () { return false; };
if (!Object.setPrototypeOf) Object.setPrototypeOf = require('setprototypeof');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of polyfilling it, should it be imported in the implementation? otherwise tests will be assuming the user has polyfilled it, which is not guaranteed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can import it in the files that are being bundled for these tests, yes. buffer itself probably wouldn't want to add it because all of the browsers that they support have setPrototypeOf.

e; On second look it's actually a little harder to put the polyfill in the bundle in these specific tests. The buffer tests have to rely on a bunch of polyfills on old Node versions unfortunately. I don't like that we're passing in things like Object to the vm sandbox, the alternative would be to do something like b.require('./test/files/buffer_polyfills.js') and stick the things buffer needs in there.

@goto-bus-stop
Copy link
Member Author

addressed by #1939

@ljharb ljharb deleted the old-node-tests branch January 9, 2020 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants