diff --git a/lib/internal/url.js b/lib/internal/url.js index ccd89830f91ded..4e257fe4bfa3f5 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -840,6 +840,9 @@ class URL { if (path.length > 0) { try { const out = new URL(path); + if (out.#context.scheme_type === 0 || out.#context.scheme_type === 2) { + return 'null'; + } if (out.#context.scheme_type !== 1) { return `${out.protocol}//${out.host}`; } diff --git a/lib/internal/v8/startup_snapshot.js b/lib/internal/v8/startup_snapshot.js index 5de746293d06e8..0e782449fdf305 100644 --- a/lib/internal/v8/startup_snapshot.js +++ b/lib/internal/v8/startup_snapshot.js @@ -2,100 +2,100 @@ const { validateFunction, -} = require('internal/validators'); +}=require('internal/validators'); const { codes: { ERR_NOT_BUILDING_SNAPSHOT, ERR_NOT_SUPPORTED_IN_SNAPSHOT, ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION, }, -} = require('internal/errors'); +}=require('internal/errors'); const { setSerializeCallback, setDeserializeCallback, setDeserializeMainFunction: _setDeserializeMainFunction, isBuildingSnapshotBuffer, -} = internalBinding('mksnapshot'); +}=internalBinding('mksnapshot'); function isBuildingSnapshot() { return isBuildingSnapshotBuffer[0]; } function throwIfNotBuildingSnapshot() { - if (!isBuildingSnapshot()) { + if(!isBuildingSnapshot()) { throw new ERR_NOT_BUILDING_SNAPSHOT(); } } function throwIfBuildingSnapshot(reason) { - if (isBuildingSnapshot()) { + if(isBuildingSnapshot()) { throw new ERR_NOT_SUPPORTED_IN_SNAPSHOT(reason); } } -const deserializeCallbacks = []; -let deserializeCallbackIsSet = false; +const deserializeCallbacks=[]; +let deserializeCallbackIsSet=false; function runDeserializeCallbacks() { - while (deserializeCallbacks.length > 0) { - const { 0: callback, 1: data } = deserializeCallbacks.shift(); + while(deserializeCallbacks.length>0) { + const {0: callback,1: data}=deserializeCallbacks.shift(); callback(data); } } -function addDeserializeCallback(callback, data) { +function addDeserializeCallback(callback,data) { throwIfNotBuildingSnapshot(); - validateFunction(callback, 'callback'); - if (!deserializeCallbackIsSet) { + validateFunction(callback,'callback'); + if(!deserializeCallbackIsSet) { // TODO(joyeecheung): when the main function handling is done in JS, // the deserialize callbacks can always be invoked. For now only // store it in C++ when it's actually used to avoid unnecessary // C++ -> JS costs. setDeserializeCallback(runDeserializeCallbacks); - deserializeCallbackIsSet = true; + deserializeCallbackIsSet=true; } - deserializeCallbacks.push([callback, data]); + deserializeCallbacks.push([callback,data]); } -const serializeCallbacks = []; +const serializeCallbacks=[]; function runSerializeCallbacks() { - while (serializeCallbacks.length > 0) { - const { 0: callback, 1: data } = serializeCallbacks.shift(); + while(serializeCallbacks.length>0) { + const {0: callback,1: data}=serializeCallbacks.shift(); callback(data); } } -function addSerializeCallback(callback, data) { +function addSerializeCallback(callback,data) { throwIfNotBuildingSnapshot(); - validateFunction(callback, 'callback'); - serializeCallbacks.push([callback, data]); + validateFunction(callback,'callback'); + serializeCallbacks.push([callback,data]); } function initializeCallbacks() { // Only run the serialize callbacks in snapshot building mode, otherwise // they throw. - if (isBuildingSnapshot()) { + if(isBuildingSnapshot()) { setSerializeCallback(runSerializeCallbacks); } } -let deserializeMainIsSet = false; -function setDeserializeMainFunction(callback, data) { +let deserializeMainIsSet=false; +function setDeserializeMainFunction(callback,data) { throwIfNotBuildingSnapshot(); // TODO(joyeecheung): In lib/internal/bootstrap/node.js, create a default // main function to run the lib/internal/main scripts and make sure that // the main function set in the snapshot building process takes precedence. - validateFunction(callback, 'callback'); - if (deserializeMainIsSet) { + validateFunction(callback,'callback'); + if(deserializeMainIsSet) { throw new ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION(); } - deserializeMainIsSet = true; + deserializeMainIsSet=true; _setDeserializeMainFunction(function deserializeMain() { const { prepareMainThreadExecution, markBootstrapComplete, - } = require('internal/process/pre_execution'); + }=require('internal/process/pre_execution'); // This should be in sync with run_main_module.js until we make that // a built-in main function. @@ -106,7 +106,7 @@ function setDeserializeMainFunction(callback, data) { }); } -module.exports = { +module.exports={ initializeCallbacks, runDeserializeCallbacks, throwIfBuildingSnapshot, diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 0269d61a649184..5d44e479db82a7 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -27,7 +27,7 @@ Last update: - resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing - resources: https://github.com/web-platform-tests/wpt/tree/919874f84f/resources - streams: https://github.com/web-platform-tests/wpt/tree/51750bc8d7/streams -- url: https://github.com/web-platform-tests/wpt/tree/c4726447f3/url +- url: https://github.com/web-platform-tests/wpt/tree/84782d9315/url - user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi diff --git a/test/fixtures/wpt/url/resources/percent-encoding.json b/test/fixtures/wpt/url/resources/percent-encoding.json index bd81edbdc35ee3..eccd1db62fe601 100644 --- a/test/fixtures/wpt/url/resources/percent-encoding.json +++ b/test/fixtures/wpt/url/resources/percent-encoding.json @@ -44,13 +44,5 @@ "output": { "utf-8": "%C3%A1|" } - }, - "Surrogate!", - { - "input": "\ud800", - "output": { - "utf-8": "%EF%BF%BD", - "windows-1252": "%26%2365533%3B" - } } ] diff --git a/test/fixtures/wpt/url/resources/urltestdata.json b/test/fixtures/wpt/url/resources/urltestdata.json index 58f6b87a8624bf..ec189871d90814 100644 --- a/test/fixtures/wpt/url/resources/urltestdata.json +++ b/test/fixtures/wpt/url/resources/urltestdata.json @@ -7755,6 +7755,21 @@ "search": "", "hash": "" }, + { + "input": "blob:http://example.org:88/", + "base": null, + "href": "blob:http://example.org:88/", + "origin": "http://example.org:88", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "http://example.org:88/", + "search": "", + "hash": "" + }, { "input": "blob:d3958f5c-0777-0845-9dcf-2cb28783acaf", "base": null, @@ -7785,6 +7800,129 @@ "search": "", "hash": "" }, + "blob: in blob:", + { + "input": "blob:blob:", + "base": null, + "href": "blob:blob:", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "blob:", + "search": "", + "hash": "" + }, + { + "input": "blob:blob:https://example.org/", + "base": null, + "href": "blob:blob:https://example.org/", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "blob:https://example.org/", + "search": "", + "hash": "" + }, + "Non-http(s): in blob:", + { + "input": "blob:about:blank", + "base": null, + "href": "blob:about:blank", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "about:blank", + "search": "", + "hash": "" + }, + { + "input": "blob:file://host/path", + "base": null, + "href": "blob:file://host/path", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "file://host/path", + "search": "", + "hash": "" + }, + { + "input": "blob:ftp://host/path", + "base": null, + "href": "blob:ftp://host/path", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "ftp://host/path", + "search": "", + "hash": "" + }, + { + "input": "blob:ws://example.org/", + "base": null, + "href": "blob:ws://example.org/", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "ws://example.org/", + "search": "", + "hash": "" + }, + { + "input": "blob:wss://example.org/", + "base": null, + "href": "blob:wss://example.org/", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "wss://example.org/", + "search": "", + "hash": "" + }, + "Percent-encoded http: in blob:", + { + "input": "blob:http%3a//example.org/", + "base": null, + "href": "blob:http%3a//example.org/", + "origin": "null", + "protocol": "blob:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "http%3a//example.org/", + "search": "", + "hash": "" + }, "Invalid IPv4 radix digits", { "input": "http://0x7f.0.0.0x7g", @@ -9362,5 +9500,35 @@ "input": "stun://[:1]", "base": null, "failure": true + }, + { + "input": "w://x:0", + "base": null, + "href": "w://x:0", + "origin": "null", + "protocol": "w:", + "username": "", + "password": "", + "host": "x:0", + "hostname": "x", + "port": "0", + "pathname": "", + "search": "", + "hash": "" + }, + { + "input": "west://x:0", + "base": null, + "href": "west://x:0", + "origin": "null", + "protocol": "west:", + "username": "", + "password": "", + "host": "x:0", + "hostname": "x", + "port": "0", + "pathname": "", + "search": "", + "hash": "" } ] diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 2b8b03da53bfa2..8d2b5aff3b90a1 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -68,7 +68,7 @@ "path": "streams" }, "url": { - "commit": "c4726447f3bad1c71244fb99c98738ff0354a034", + "commit": "84782d931516aa13cfe32dc7eaa1377b4d947d66", "path": "url" }, "user-timing": {