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

Adding tests for Array.prototype.copyWithin #2443

Merged
merged 2 commits into from Dec 18, 2019
Merged

Conversation

natashenka
Copy link
Contributor

A security test for copyWithin. This checks that Array.prototype.copyWithin behaves correctly in the case that converting the start parameter to an integer has side effects. This caused a security bug in Moddable Moddable-OpenSource/moddable#123

@ljharb
Copy link
Member

ljharb commented Dec 4, 2019

I tried adding these tests to the es6-shim; the "coerced-values-start-change-start" tests appear to fail in latest node (where the implementation is native), as well as with the es6-shim applied in both latest node and 0.10.

Specifically, it's getting an empty array where it expects a dense array of 24 undefineds - perhaps my test framework's assertion is incorrect (maybe it's different than compareArray), but can you confirm what the expected values should be for these tests?

@natashenka
Copy link
Contributor Author

Yeah, I think this is a difference in how compare array works. The correct array to return is an empty array of length 20, but when it gets compared, the value is converted to undefined anyhow, but I'm guessing that doesn't happen in your harness. Anyhow, I updated it to compare the empty array, this makes it simpler, and hopefully will work with your harness as well.

ljharb added a commit to ljharb/es6-shim that referenced this pull request Dec 4, 2019
ljharb added a commit to paulmillr/es6-shim that referenced this pull request Dec 5, 2019
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Tests pass on es6-shim on all envs as well as natively on v8.

@natashenka
Copy link
Contributor Author

Just following up here. Is there anything I need to do to get this merged?

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

Successfully merging this pull request may close these issues.

None yet

3 participants