Skip to content

Commit

Permalink
test: update URL web-platform-tests
Browse files Browse the repository at this point in the history
PR-URL: nodejs#47135
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
anonrig committed Jun 26, 2023
1 parent a252008 commit b92badd
Show file tree
Hide file tree
Showing 8 changed files with 602 additions and 26 deletions.
17 changes: 9 additions & 8 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@ See [test/wpt](../../wpt/README.md) for information on how these tests are run.

Last update:

- common: https://github.com/web-platform-tests/wpt/tree/03c5072aff/common
- common: https://github.com/web-platform-tests/wpt/tree/dbd648158d/common
- console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console
- dom/abort: https://github.com/web-platform-tests/wpt/tree/8fadb38120/dom/abort
- dom/events: https://github.com/web-platform-tests/wpt/tree/ab8999891c/dom/events
- encoding: https://github.com/web-platform-tests/wpt/tree/0c1b9d1622/encoding
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
- FileAPI: https://github.com/web-platform-tests/wpt/tree/3b279420d4/FileAPI
- FileAPI/file: https://github.com/web-platform-tests/wpt/tree/c01f637cca/FileAPI/file
- FileAPI: https://github.com/web-platform-tests/wpt/tree/1e432c4550/FileAPI
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
- interfaces: https://github.com/web-platform-tests/wpt/tree/fc086c82d5/interfaces
- interfaces: https://github.com/web-platform-tests/wpt/tree/df731dab88/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
- resources: https://github.com/web-platform-tests/wpt/tree/fbf1e7d247/resources
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
- url: https://github.com/web-platform-tests/wpt/tree/1eaeb0e178/url
- 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/84caeb6fbd/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/ee30029d47/WebCryptoAPI
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/1406b5c0d0/WebCryptoAPI
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel

[Web Platform Tests]: https://github.com/web-platform-tests/wpt
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/main/docs/git-node.md#git-node-wpt
63 changes: 63 additions & 0 deletions test/fixtures/wpt/url/javascript-urls.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// The results of this test are all over the map due to browsers behaving very differently for
// javascript: URLs.
//
// Chromium is pretty close execution-wise, but it parses javascript: URLs incorrectly.
// Gecko navigates to non-string return values of the result of executing a javascript: URL.
// WebKit executes javascript: URLs too early and has a harness error due to URL parsing.
//
// The expectations below should match the HTML and URL standards.
[
{
"description": "javascript: URL that fails to parse due to invalid host",
"input": "javascript://test:test/%0aglobalThis.shouldNotExistA=1",
"property": "shouldNotExistA",
"expected": undefined
},
{
"description": "javascript: URL that fails to parse due to invalid host and has a U+0009 in scheme",
"input": "java\x09script://test:test/%0aglobalThis.shouldNotExistB=1",
"property": "shouldNotExistB",
"expected": undefined
},
{
"description": "javascript: URL without an opaque path",
"input": "javascript://host/1%0a//../0/;globalThis.shouldBeOne=1;/%0aglobalThis.shouldBeOne=2;/..///",
"property": "shouldBeOne",
"expected": 1
},
{
"description": "javascript: URL containing a JavaScript string split over path and query",
// Use ";undefined" to avoid returning a string.
"input": "javascript:globalThis.shouldBeAStringA = \"https://whatsoever.com/?a=b&c=5&x=y\";undefined",
"property": "shouldBeAStringA",
"expected": "https://whatsoever.com/?a=b&c=5&x=y"
},
{
"description": "javascript: URL containing a JavaScript string split over path and query and has a U+000A in scheme",
// Use ";undefined" to avoid returning a string.
"input": "java\x0Ascript:globalThis.shouldBeAStringB = \"https://whatsoever.com/?a=b&c=5&x=y\";undefined",
"property": "shouldBeAStringB",
"expected": "https://whatsoever.com/?a=b&c=5&x=y"
}
].forEach(({ description, input, property, expected }) => {
// Use promise_test so the tests run in sequence. Needed for globalThis.verify below.
promise_test(t => {
const anchor = document.body.appendChild(document.createElement("a"));
t.add_cleanup(() => anchor.remove());
anchor.href = input;
assert_equals(globalThis[property], undefined, "Property is undefined before the click");
anchor.click();
assert_equals(globalThis[property], undefined, "Property is undefined immediately after the click");

// Since we cannot reliably queue a task to run after the task queued as a result of the click()
// above, we do another click() with a new URL.
return new Promise(resolve => {
globalThis.verify = t.step_func(() => {
assert_equals(globalThis[property], expected, `Property is ${expected} once the navigation happened`);
resolve();
});
anchor.href = "javascript:globalThis.verify()";
anchor.click();
});
}, description);
});
72 changes: 72 additions & 0 deletions test/fixtures/wpt/url/resources/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,42 @@
"host": "",
"hostname": ""
}
},
{
"href": "https://example.com/",
"new_value": "a%C2%ADb",
"expected": {
"href": "https://ab/",
"host": "ab",
"hostname": "ab"
}
},
{
"href": "https://example.com/",
"new_value": "\u00AD",
"expected": {
"href": "https://example.com/",
"host": "example.com",
"hostname": "example.com"
}
},
{
"href": "https://example.com/",
"new_value": "%C2%AD",
"expected": {
"href": "https://example.com/",
"host": "example.com",
"hostname": "example.com"
}
},
{
"href": "https://example.com/",
"new_value": "xn--",
"expected": {
"href": "https://example.com/",
"host": "example.com",
"hostname": "example.com"
}
}
],
"hostname": [
Expand Down Expand Up @@ -1436,6 +1472,42 @@
"host": "",
"hostname": ""
}
},
{
"href": "https://example.com/",
"new_value": "a%C2%ADb",
"expected": {
"href": "https://ab/",
"host": "ab",
"hostname": "ab"
}
},
{
"href": "https://example.com/",
"new_value": "\u00AD",
"expected": {
"href": "https://example.com/",
"host": "example.com",
"hostname": "example.com"
}
},
{
"href": "https://example.com/",
"new_value": "%C2%AD",
"expected": {
"href": "https://example.com/",
"host": "example.com",
"hostname": "example.com"
}
},
{
"href": "https://example.com/",
"new_value": "xn--",
"expected": {
"href": "https://example.com/",
"host": "example.com",
"hostname": "example.com"
}
}
],
"port": [
Expand Down
17 changes: 0 additions & 17 deletions test/fixtures/wpt/url/resources/toascii.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,6 @@
"input": "a\u00ADb",
"output": "ab"
},
{
"input": "a%C2%ADb",
"output": "ab"
},
{
"comment": "Empty host after domain to ASCII",
"input": "\u00AD",
"output": null
},
{
"input": "%C2%AD",
"output": null
},
{
"input": "xn--",
"output": null
},
{
"comment": "Interesting UseSTD3ASCIIRules=false cases",
"input": "",
Expand Down
Loading

0 comments on commit b92badd

Please sign in to comment.