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

Only add defined properties to the result of getOwnPropertyDescriptors #1345

Merged
merged 1 commit into from
Jul 29, 2016

Conversation

j-wing
Copy link
Contributor

@j-wing j-wing commented Jul 27, 2016

Fixes #1342

For the tests for this change, I adapted @ljharb's tests from the discussion he linked to in the issue and trimmed it down to test just this change.

@msftclas
Copy link

Hi @jordonwii, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Jordon Wing). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

body: function() {
// Adapted from: https://github.com/ljharb/test262/blob/c2eaa30b08fb1e041b7297e415b6bad8461f50dc/test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js
var proxyHandler = {
getOwnPropertyDescriptor: function () {},
Copy link
Collaborator

@ljharb ljharb Jul 27, 2016

Choose a reason for hiding this comment

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

This bug is only truly testable if ownKeys returns a key, that getOwnPropertyDescriptor returns undefined for - so it's critical to define ownKeys to return [key] (or to define the target as { a: something }), otherwise you're not testing anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I misunderstood how that was being used, and removed the ownKeys bit as a last minute change. I'll add that back in.

@akroshg
Copy link
Contributor

akroshg commented Jul 28, 2016

Code wise looks good to me. Did you update the test accordingly?
@ianwjhalliday should have the final review on this.

@j-wing
Copy link
Contributor Author

j-wing commented Jul 28, 2016

@akroshg I didn't have a chance to update it yesterday, but I just did now. I also confirmed that the test fails without my change, and passes with it.

assert.areEqual(undefined, descriptor, "Descriptor matches result of [[GetOwnPropertyDescriptor]] trap");

var result = Object.getOwnPropertyDescriptors(proxy);
assert.isFalse(key in result, "key should not be present in result");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The in operator also returns true for properties found in the prototype change. Here we don't expect the prototype change of a normal plain object to have a property named 'a', but it would be better practice to use obj.hasOwnProperty(key) instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Fixed!

@ianwjhalliday
Copy link
Collaborator

Looks great. One comment on the test that I think should be addressed, otherwise good to go.

@chakrabot chakrabot merged commit 761bcd2 into chakra-core:master Jul 29, 2016
chakrabot pushed a commit that referenced this pull request Jul 29, 2016
… getOwnPropertyDescriptors

Merge pull request #1345 from jordonwii:issue1342

Fixes #1342

For the tests for this change, I adapted @ljharb's tests from the discussion he linked to in the issue and trimmed it down to test just this change.
@ianwjhalliday
Copy link
Collaborator

Thanks @jordonwii

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.

6 participants