FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

url,lib: pass urlsearchparams-constructor.any.js by XadillaX · Pull Request #39944 · nodejs/node · GitHub

/ node Public

url,lib: pass urlsearchparams-constructor.any.js - #39944

Closed
XadillaX wants to merge 1 commit into
nodejs:masterfrom
XadillaX:urlsearchparams-constructor.any.js
Closed

url,lib: pass urlsearchparams-constructor.any.js#39944
XadillaX wants to merge 1 commit into
nodejs:masterfrom
XadillaX:urlsearchparams-constructor.any.js

Conversation

XadillaX commented Aug 30, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

According to WPT:

  1. URLSearchParams constructor should throw exactly TypeError if any
    Error occurrs.
  2. When a record passed to URLSearchParams constructor, two different
    key may result same after toUVString(). We should leave only the
    later one.

nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Aug 30, 2021
XadillaX force-pushed the urlsearchparams-constructor.any.js branch 2 times, most recently from 64340bb to 2e3cdde Compare August 31, 2021 06:36
XadillaX changed the title [WIP] url,lib: pass urlsearchparams-constructor.any.js url,lib: pass urlsearchparams-constructor.any.js Aug 31, 2021
XadillaX force-pushed the urlsearchparams-constructor.any.js branch 2 times, most recently from 9143796 to fe1db8f Compare August 31, 2021 06:45
Comment thread lib/internal/url.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If you look at lib/internals/errors.js, you'll see that ERR_ARG_NOT_ITERABLE is already a TypeError.

Comment thread lib/internal/url.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ERR_INVALID_TUPLE is already a TypeError

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It needs error.constructor equals to TypeError. So inheritance is not allowed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would argue that's a bug in the test harness and not our implementation.

const e = new ERR_INVALID_TUPLE('a', 'b');
console.log(e instanceof TypeError); // true

The spec text says only to throw a TypeError, and that is what we're doing here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

our internal errors already satisfy this constraint:

> try { new URLSearchParams([1]) } catch(err) { console.log(err.constructor === TypeError) }
true

XadillaX Aug 31, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

2 ways to resolve it:

  1. Ignore this case: new URLSearchParams(DOMException.prototype);
  2. Fix the code to pass wpt.

Both of the two ways are OK, but current code can't pass that case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It was fixed in #33857

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'll take a look later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

But new URLSearchParams(DOMException.prototype); is thrown by DOMException.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@targos You're right. The only thing I should fix for error handling is the ERR_INVALID_THIS in lib/internal/per_context/domexception.js.

Comment thread lib/internal/url.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is not the correct way of handling this. If you take a look at lib/internals/errors.js, you'll see that some error codes have multiple types in their list... for instance ERR_INVALID_STATE lists Error, TypeError, and RangeError. To create an ERR_INVALID_STATE error this is a TypeError, you simply do new ERR_INVALID_STATE.TypeError("message")

jasnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The TypeError handling in this is not correct. Haven't looked at the rest yet.

XadillaX force-pushed the urlsearchparams-constructor.any.js branch 2 times, most recently from 7b72a8c to 4c101fc Compare September 1, 2021 03:29
XadillaX requested a review from jasnell September 1, 2021 03:31

XadillaX commented Sep 2, 2021

Copy link
Copy Markdown
Contributor Author

The TypeError handling in this is not correct. Haven't looked at the rest yet.

I've fixed them.

XadillaX commented Sep 6, 2021

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

XadillaX commented Sep 7, 2021

Copy link
Copy Markdown
Contributor Author

/ping @jasnell again :)

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

targos commented Sep 13, 2021

Copy link
Copy Markdown
Member

@nodejs/url

This comment has been minimized.

This comment has been minimized.

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Contributor Author

I think this PR need @jasnell to approve because he gave a Change Requested.

/ping @jasnell

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

Comment thread test/wpt/test-url.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If we decided to add FormData later someone might miss removing this. It would be worthwhile making this replacement dependent on whether FormData is undefined.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done. I've add typeof FormData === 'undefined'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

/ping @jasnell

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

/ping @jasnell

XadillaX force-pushed the urlsearchparams-constructor.any.js branch from 4c101fc to 4b8ea64 Compare September 17, 2021 03:59

This comment has been minimized.

According to WPT:

1. `URLSearchParams` constructor should throw exactly `TypeError` if any
   Error occurrs.
2. When a record passed to `URLSearchParams` constructor, two different
   key may result same after `toUVString()`. We should leave only the
   later one.
XadillaX force-pushed the urlsearchparams-constructor.any.js branch from 4b8ea64 to c2e77f2 Compare September 17, 2021 04:01

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Contributor Author

/ping @jasnell Could you please take a minute to review this PR again? Thanks.

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

1 similar comment

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

XadillaX commented Oct 3, 2021

Copy link
Copy Markdown
Contributor Author

/ping @jasnell again.

XadillaX commented Oct 8, 2021

Copy link
Copy Markdown
Contributor Author

Hi @jasnell, would you please to review this PR again?

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

1 similar comment

XadillaX commented Nov 3, 2021

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

watilde added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 3, 2021
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 3, 2021

Copy link
Copy Markdown
Collaborator

XadillaX commented Nov 5, 2021

Copy link
Copy Markdown
Contributor Author

/ping @jasnell again

Copy link
Copy Markdown
Contributor Author

/ping @jasnell

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL