Skip to content

Commit

Permalink
add bodymixin bytes (#3262)
Browse files Browse the repository at this point in the history
* add bodymixin bytes

* use git node wpt instead of sparse-checkout

* fixup?

* fixup

* fixup
  • Loading branch information
KhafraDev committed May 15, 2024
1 parent 903c667 commit e2dc4da
Show file tree
Hide file tree
Showing 3,118 changed files with 7,189 additions and 20,385 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
56 changes: 14 additions & 42 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,51 +94,23 @@ Create a commit which includes all of the updated files in lib/llhttp.

`undici` runs a subset of the [`web-platform-tests`](https://github.com/web-platform-tests/wpt).

Here are the steps to update them.
### Requirements:
- [Node core utils](https://github.com/nodejs/node-core-utils) setup with credentials.

<details>
<summary>Skip the tutorial</summary>
To update every test, run the following commands. Typically you would only need to update the tests in a specific directory.

```bash
git clone --depth 1 --single-branch --branch epochs/daily --filter=blob:none --sparse https://github.com/web-platform-tests/wpt.git test/wpt/tests
cd test/wpt/tests

git sparse-checkout add /resources
git sparse-checkout add /interfaces
git sparse-checkout add /common
git sparse-checkout add /fetch
git sparse-checkout add /FileAPI
git sparse-checkout add /xhr
git sparse-checkout add /websockets
git sparse-checkout add /mimesniff
git sparse-checkout add /storage
git sparse-checkout add /service-workers
```

</details>

#### Sparse-clone the [wpt](https://github.com/web-platform-tests/wpt) repo

```bash
git clone --depth 1 --single-branch --branch epochs/daily --filter=blob:none --sparse https://github.com/web-platform-tests/wpt.git test/wpt/tests

cd test/wpt/tests

```

#### Checkout the tests

Only run the commands for the folder(s) you want to update.

```bash
git sparse-checkout add /fetch
git sparse-checkout add /FileAPI
git sparse-checkout add /xhr
git sparse-checkout add /websockets
git sparse-checkout add /resources
git sparse-checkout add /common

# etc
git node wpt resources
git node wpt interfaces
git node wpt common
git node wpt fetch
git node wpt FileAPI
git node wpt xhr
git node wpt websockets
git node wpt mimesniff
git node wpt storage
git node wpt service-workers
git node wpt eventsource
```

#### Run the tests
Expand Down
9 changes: 9 additions & 0 deletions lib/web/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,15 @@ function bodyMixinMethods (instance) {
'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
)
}, instance, false)
},

bytes () {
// The bytes() method steps are to return the result of running consume body
// with this and the following step given a byte sequence bytes: return the
// result of creating a Uint8Array from bytes in this’s relevant realm.
return consumeBody(this, (bytes) => {
return new Uint8Array(bytes)
}, instance, true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"ignore": [
"lib/llhttp/constants.js",
"lib/llhttp/utils.js",
"test/wpt/tests"
"test/fixtures/wpt"
]
},
"tsd": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@ test_blob(function() {
new Int16Array([0x4150, 0x5353]),
new Uint32Array([0x53534150]),
new Int32Array([0x53534150]),
new Float16Array([2.65625, 58.59375]),
new Float32Array([0xD341500000])
]);
}, {
expected: "PASSPASSPASSPASSPASSPASSPASS",
expected: "PASSPASSPASSPASSPASSPASSPASSPASS",
type: "",
desc: "Passing typed arrays as elements of the blobParts array should work."
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Web Platform Test Fixtures

The files in this folder, including this document,
are generated by [`git node wpt`][].

This folder contains a subset of the [Web Platform Tests][] for the
implementation of Web APIs in Node.js.

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/8bfc72a4f7/common
- eventsource: https://github.com/web-platform-tests/wpt/tree/93ca7d3363/eventsource
- fetch: https://github.com/web-platform-tests/wpt/tree/1b9332c3c8/fetch
- FileAPI: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/FileAPI
- interfaces: https://github.com/web-platform-tests/wpt/tree/40d3681ef5/interfaces
- mimesniff: https://github.com/web-platform-tests/wpt/tree/0e9d465d28/mimesniff
- resources: https://github.com/web-platform-tests/wpt/tree/34dfef83fc/resources
- service-workers: https://github.com/web-platform-tests/wpt/tree/3ebc2c5109/service-workers
- storage: https://github.com/web-platform-tests/wpt/tree/9f1cfd6824/storage
- websockets: https://github.com/web-platform-tests/wpt/tree/a7a594d8c0/websockets
- xhr: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/xhr

[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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ function getVideoURI(base)
if (videotag.canPlayType('video/webm; codecs="vp9, opus"') )
{
extension = '.webm';
} else if ( videotag.canPlayType('video/ogg; codecs="theora, vorbis"') )
{
extension = '.ogv';
}
}

Expand Down Expand Up @@ -52,7 +49,6 @@ function getMediaContentType(url) {
var extension = new URL(url, location).pathname.split(".").pop();
var map = {
"mp4" : "video/mp4",
"ogv" : "application/ogg",
"webm": "video/webm",
"mp3" : "audio/mp3",
"oga" : "application/ogg",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def generate_test_source_files(spec_directory, test_helper_filenames,
# Choose a debug/release template depending on the target.
html_template = "test.%s.html.template" % target

artifact_order = test_expansion_schema.keys()
artifact_order = list(test_expansion_schema.keys())
artifact_order.remove('expansion')

excluded_selection_pattern = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def assert_non_empty_string(obj, field):
assert field in obj, 'Missing field "%s"' % field
assert isinstance(obj[field], basestring), \
assert isinstance(obj[field], str), \
'Field "%s" must be a string' % field
assert len(obj[field]) > 0, 'Field "%s" must not be empty' % field

Expand Down Expand Up @@ -34,7 +34,7 @@ def assert_value_from(obj, field, items):


def assert_atom_or_list_items_from(obj, field, items):
if isinstance(obj[field], basestring) or isinstance(
if isinstance(obj[field], str) or isinstance(
obj[field], int) or obj[field] is None:
assert_value_from(obj, field, items)
return
Expand Down Expand Up @@ -236,7 +236,7 @@ def assert_valid_spec_json(spec_json):
try:
validate(spec_json, error_details)
except AssertionError as err:
print('ERROR:', err.message)
print('ERROR:', err)
print(json.dumps(error_details, indent=4))
sys.exit(1)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e2dc4da

Please sign in to comment.