Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add tests for Function.prototype.caller and arguments properties #4355
base: main
Are you sure you want to change the base?
Add tests for Function.prototype.caller and arguments properties #4355
Changes from 2 commits
1c42cfc
9875dd4
8ec9d7c
527fc5f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sec-function.prototype.caller
does not appear to be a valid anchor: https://tc39.es/ecma262/#sec-function.prototype.callerSee also CONTRIBUTING.md: Test Case Style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already covered by the existing tests in:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nice! Then this PR can be largely refactored to modernize those existing tests.
test/built-ins/Function/prototype/restricted-property-arguments.js → test/built-ins/Function/prototype/arguments/prop-desc.js
test/built-ins/Function/prototype/restricted-property-caller.js → test/built-ins/Function/prototype/caller/prop-desc.js
(analogous, replacing
arguments
withcaller
)By the way @anba, how are you finding the existing coverage? It's something that I struggle with, especially in the case of test subdirectories that heavily use old patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gibson042 I added the refactored tests. For the other files I'm not sure what to do. Should I still address the issues or will they be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gibson042 @anba Should I still address the other reviews/suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the ones I mentioned above, I'm asking for this PR to remove test/built-ins/Function/prototype/{restricted-property-arguments.js,restricted-property-caller.js} and replace them with test/built-ins/Function/prototype/{arguments,caller}/prop-desc.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect:
%ThrowTypeError%
is defined once per realm, cf. https://tc39.es/ecma262/#sec-%throwtypeerror%.See also https://github.com/tc39/test262/blob/main/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions are implicitly in strict-mode when defined in modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
"use strict"
to makestrictFunc
actually a strict-mode function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strict-mode case is already covered by:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should modernize that as well, introducing a helper like
verifyNoRestrictedFunctionProperties
and using it at e.g.var f = function(){};
and generalizations, in script and module code)function f(){}
and generalizations, in script and module code)var m = new (class { m(){} })().m
, in script and module code)get
/set
accessors$Function()
and$Function('"use strict"')
, or alternatively split into a pair of files)and removing all other restricted-properties files.