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

lib: mark URL/URLSearchParams as uncloneable and untransferable #47497

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const {
SideEffectFreeRegExpPrototypeSymbolReplace,
} = require('internal/util');

const {
markTransferMode,
} = require('internal/worker/js_transferable');

const {
codes: {
ERR_ARG_NOT_ITERABLE,
Expand Down Expand Up @@ -326,6 +330,8 @@ class URLSearchParams {
// Default parameter is necessary to keep URLSearchParams.length === 0 in
// accordance with Web IDL spec.
constructor(init = undefined) {
markTransferMode(this, false, false);

if (init == null) {
// Do nothing
} else if (typeof init === 'object' || typeof init === 'function') {
Expand Down Expand Up @@ -761,6 +767,8 @@ class URL {
#searchParams;

constructor(input, base = undefined) {
markTransferMode(this, false, false);

if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('url');
}
Expand Down
4 changes: 1 addition & 3 deletions test/wpt/status/url.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"fail": {
"note": "We are faking location with a URL object for the sake of the testharness and it has searchParams.",
"expected": [
"searchParams on location object",
"URL: no structured serialize/deserialize support",
"URLSearchParams: no structured serialize/deserialize support"
"searchParams on location object"
]
}
},
Expand Down