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

[Merged by Bors] - Implement escape and unescape #2768

Closed
wants to merge 6 commits into from

Conversation

jedel1043
Copy link
Member

This Pull Request implements the escape and unescape functions.

Both are technically deprecated, but they're also part of the Additional ECMAScript Features for Web Browsers section, so it is preferable to have them in place.

@jedel1043 jedel1043 added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics labels Mar 31, 2023
@jedel1043 jedel1043 added this to the v0.17.0 milestone Mar 31, 2023
@github-actions
Copy link

github-actions bot commented Mar 31, 2023

Test262 conformance changes

Test result main count PR count difference
Total 94,343 94,343 0
Passed 71,100 71,170 +70
Ignored 17,386 17,386 0
Failed 5,857 5,787 -70
Panics 0 0 0
Conformance 75.36% 75.44% +0.07%
Fixed tests (70):
test/annexB/built-ins/escape/to-string-err-symbol.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/to-string-err-symbol.js (previously Failed)
test/annexB/built-ins/escape/length.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/length.js (previously Failed)
test/annexB/built-ins/escape/empty-string.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/empty-string.js (previously Failed)
test/annexB/built-ins/escape/unmodified.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/unmodified.js (previously Failed)
test/annexB/built-ins/escape/to-string-err.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/to-string-err.js (previously Failed)
test/annexB/built-ins/escape/escape-above-astral.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/escape-above-astral.js (previously Failed)
test/annexB/built-ins/escape/escape-above.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/escape-above.js (previously Failed)
test/annexB/built-ins/escape/name.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/name.js (previously Failed)
test/annexB/built-ins/escape/to-primitive-observe.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/to-primitive-observe.js (previously Failed)
test/annexB/built-ins/escape/argument_types.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/argument_types.js (previously Failed)
test/annexB/built-ins/escape/prop-desc.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/prop-desc.js (previously Failed)
test/annexB/built-ins/escape/not-a-constructor.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/not-a-constructor.js (previously Failed)
test/annexB/built-ins/escape/to-string-observe.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/to-string-observe.js (previously Failed)
test/annexB/built-ins/escape/escape-below.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/escape-below.js (previously Failed)
test/annexB/built-ins/escape/to-primitive-err.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/to-primitive-err.js (previously Failed)
test/annexB/built-ins/escape/argument_bigint.js [strict mode] (previously Failed)
test/annexB/built-ins/escape/argument_bigint.js (previously Failed)
test/annexB/built-ins/unescape/to-string-err-symbol.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/to-string-err-symbol.js (previously Failed)
test/annexB/built-ins/unescape/two-ignore-non-hex.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/two-ignore-non-hex.js (previously Failed)
test/annexB/built-ins/unescape/two.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/two.js (previously Failed)
test/annexB/built-ins/unescape/four-ignore-non-hex.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/four-ignore-non-hex.js (previously Failed)
test/annexB/built-ins/unescape/length.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/length.js (previously Failed)
test/annexB/built-ins/unescape/empty-string.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/empty-string.js (previously Failed)
test/annexB/built-ins/unescape/to-string-err.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/to-string-err.js (previously Failed)
test/annexB/built-ins/unescape/two-ignore-end-str.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/two-ignore-end-str.js (previously Failed)
test/annexB/built-ins/unescape/four-ignore-bad-u.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/four-ignore-bad-u.js (previously Failed)
test/annexB/built-ins/unescape/name.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/name.js (previously Failed)
test/annexB/built-ins/unescape/to-primitive-observe.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/to-primitive-observe.js (previously Failed)
test/annexB/built-ins/unescape/argument_types.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/argument_types.js (previously Failed)
test/annexB/built-ins/unescape/prop-desc.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/prop-desc.js (previously Failed)
test/annexB/built-ins/unescape/four.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/four.js (previously Failed)
test/annexB/built-ins/unescape/four-ignore-end-str.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/four-ignore-end-str.js (previously Failed)
test/annexB/built-ins/unescape/not-a-constructor.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/not-a-constructor.js (previously Failed)
test/annexB/built-ins/unescape/to-string-observe.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/to-string-observe.js (previously Failed)
test/annexB/built-ins/unescape/to-primitive-err.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/to-primitive-err.js (previously Failed)
test/annexB/built-ins/unescape/argument_bigint.js [strict mode] (previously Failed)
test/annexB/built-ins/unescape/argument_bigint.js (previously Failed)

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Merging #2768 (d0fe6d1) into main (540aa2b) will decrease coverage by 0.07%.
The diff coverage is 24.44%.

@@            Coverage Diff             @@
##             main    #2768      +/-   ##
==========================================
- Coverage   50.98%   50.92%   -0.07%     
==========================================
  Files         409      410       +1     
  Lines       40759    40849      +90     
==========================================
+ Hits        20781    20802      +21     
- Misses      19978    20047      +69     
Impacted Files Coverage Δ
boa_tester/src/edition.rs 0.00% <ø> (ø)
boa_engine/src/builtins/escape/mod.rs 15.00% <15.00%> (ø)
boa_engine/src/builtins/mod.rs 100.00% <100.00%> (ø)
boa_engine/src/context/intrinsics.rs 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

It looks great to me, but I would put this behind a feature flag, since this should only be enabled for browsers:

When the ECMAScript host is a web browser the following additional properties of the standard built-in objects are defined.

@jedel1043
Copy link
Member Author

It looks great to me, but I would put this behind a feature flag, since this should only be enabled for browsers:

When the ECMAScript host is a web browser the following additional properties of the standard built-in objects are defined.

Thought about it, but I checked Node and Deno and both have these functions enabled, probably because of compatibility purposes... Though, we have plans for feature gating all builtins anyways, so maybe it should be fine to gate them, then add them to the default set of features?

@Razican
Copy link
Member

Razican commented Mar 31, 2023

It looks great to me, but I would put this behind a feature flag, since this should only be enabled for browsers:

When the ECMAScript host is a web browser the following additional properties of the standard built-in objects are defined.

Thought about it, but I checked Node and Deno and both have these functions enabled, probably because of compatibility purposes... Though, we have plans for feature gating all builtins anyways, so maybe it should be fine to gate them, then add them to the default set of features?

I would feature gate them and add them to the default set, but in the future, I can imagine having:

  • default: base + built-ins + browser (anex B) + intl
  • base: basic language, no built-ins
  • built-ins: non-anex-B built-ins
  • intl: intl module

Then, I would like to have one feature for each feature in test262, ideally, or at least one feature per built-in + async/await + generators... in case users would like to block some functionality. They should also be able to create a context with no features and cherry pick the built-ins at runtime, for example.

But this is out of this PR, of course. I would still add the feature gate, though :)

@raskad
Copy link
Member

raskad commented Apr 1, 2023

Right now this is missing Escape::init(&intrinsics); and Unescape::init(&intrinsics); in Intrinsics::new(). The functions are just empty objects, that is why only the negative tests are passing. After that there are two tests in unescape that are failing, but I'm currently not sure why.

@jedel1043
Copy link
Member Author

Right now this is missing Escape::init(&intrinsics); and Unescape::init(&intrinsics); in Intrinsics::new(). The functions are just empty objects, that is why only the negative tests are passing. After that there are two tests in unescape that are failing, but I'm currently not sure why.

Remind me to not push changes at 4am again 🙃 Thanks for the catch!

@jedel1043 jedel1043 marked this pull request as draft April 2, 2023 17:05
@jedel1043 jedel1043 marked this pull request as ready for review April 3, 2023 18:49
@jedel1043
Copy link
Member Author

Ok, all tests are passing for me and I gated the functions behind an annex-b feature.

@jedel1043 jedel1043 requested a review from Razican April 3, 2023 19:10
@jedel1043 jedel1043 requested a review from Razican April 3, 2023 21:20
@jedel1043 jedel1043 requested a review from HalidOdat April 3, 2023 21:20
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! :)

@raskad
Copy link
Member

raskad commented Apr 3, 2023

bors r+

bors bot pushed a commit that referenced this pull request Apr 3, 2023
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel necessary.
--->

This Pull Request implements the [`escape`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape) and [`unescape`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape) functions.

Both are technically deprecated, but they're also part of the [Additional ECMAScript Features for Web Browsers](https://tc39.es/ecma262/#sec-additional-ecmascript-features-for-web-browsers) section, so it is preferable to have them in place.
@bors
Copy link

bors bot commented Apr 3, 2023

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implement escape and unescape [Merged by Bors] - Implement escape and unescape Apr 3, 2023
@bors bors bot closed this Apr 3, 2023
@bors bors bot deleted the escape-unescape branch April 3, 2023 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants