Skip to content

Conversation

tuchida
Copy link
Contributor

@tuchida tuchida commented Mar 9, 2022

@@ -507,6 +513,30 @@ public Object execIdCall(
Scriptable desc = obj.getOwnPropertyDescriptor(cx, nameArg);
return desc == null ? Undefined.instance : desc;
}
case ConstructorId_getOwnPropertyDescriptors:
Copy link
Collaborator

Choose a reason for hiding this comment

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

EcmaScript spec says the getOwnPropertyDescriptors impl should use the CreateDataPropertyOrThrow Abstract Object operation

We don't have such method yet in AbstractEcmaObjectOperations yet. Would it make sense to refactor things (assuming that the logic of that Abstract Operation is already covered elsewhere) into the appropriate method in AbstractEcmaObjectOperations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps CreateDataPropertyOrThrow looks like the same behavior as defineOwnProperty(cx, id, desc, checkValid = true).

protected void defineOwnProperty(
Context cx, Object id, ScriptableObject desc, boolean checkValid) {

I could use defineOwnProperty here, but I couldn't think of a test case. And, I think we will need FromPropertyDescriptor too. If any test case is violated by this PR, I will be fixed it.

case ConstructorId_getOwnPropertyDescriptors:
{
Object arg = args.length < 1 ? Undefined.instance : args[0];
// TODO(norris): There's a deeper issue here if
Copy link
Collaborator

Choose a reason for hiding this comment

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

A super minor thing but I don't think that we should add a new TODO comment when copying code, especially one that I bet is 10+ years old and assigned to someone who hasn't worked on this project for a very long time ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref. 2b80a8a I removed. I will fixup in a few days.

@gbrail
Copy link
Collaborator

gbrail commented Mar 12, 2022

I got tripped up by that TODO comment and I think you should just take it out -- see above. It's minor but if you can please address that then I think we should merge this. Thanks!

@gbrail
Copy link
Collaborator

gbrail commented Mar 18, 2022

This looks good -- thanks!

@gbrail gbrail merged commit c696e34 into mozilla:master Mar 18, 2022
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.

Implement ES2017 Object.getOwnPropertyDescriptors
3 participants