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

Add bytes() method for reading bytes into a Uint8Array #370

Merged
merged 1 commit into from
May 30, 2024

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented May 21, 2024

Closes #369

The Fetch API is getting a Uint8Array-returning bytes() method alongside its existing arrayBuffer() method, following the principle that APIs should generally vend byte buffers as Uint8Arrays.

This PR makes the same change for PushMessageData, which has its own distinct arrayBuffer method.

I'm assuming this is uncontroversial given the support from the three major implementations for doing this on Body, but I can open an issue and solicit explicit support separately if you'd prefer. I'll write tests if I get a signal that this is able to go forward.

It's unfortunate that getKey and applicationServerKey vend ArrayBuffers instead of Uint8Arrays, but it's too late to fix those now.

The following tasks have been completed:

Implementation commitment:


Preview | Diff

@marcoscaceres
Copy link
Member Author

Filed Gecko bug.

@marcoscaceres
Copy link
Member Author

marcoscaceres commented May 21, 2024

@martinthomson, @beverloo, looking for interest from a second implementer (and no objections from the third).

webkit-commit-queue pushed a commit to annevk/WebKit that referenced this pull request May 24, 2024
https://bugs.webkit.org/show_bug.cgi?id=274119
rdar://128418858

Reviewed by Youenn Fablet.

This implements w3c/FileAPI#198 and
w3c/push-api#370 creating parity for these
APIs with Fetch's Body.

This incorporates the tests from
web-platform-tests/wpt#46232 modulo a typo fix.
PushMessageData test coverage is done through a local test that would
be good to upstream at some point.

* LayoutTests/http/wpt/push-api/pushEvent.any.js:
(test):
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/Blob-methods-from-detached-frame-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/Blob-methods-from-detached-frame.html:
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.js: Added.
(string_appeared_here.promise_test.async const):
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.worker-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.worker.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/w3c-import.log:
* Source/WebCore/Modules/push-api/PushMessageData.cpp:
(WebCore::PushMessageData::arrayBuffer):
(WebCore::PushMessageData::bytes):
* Source/WebCore/Modules/push-api/PushMessageData.h:
* Source/WebCore/Modules/push-api/PushMessageData.idl:
* Source/WebCore/fileapi/Blob.cpp:
(WebCore::Blob::arrayBuffer):
(WebCore::Blob::bytes):
* Source/WebCore/fileapi/Blob.h:
* Source/WebCore/fileapi/Blob.idl:

Canonical link: https://commits.webkit.org/279263@main
@evilpie
Copy link

evilpie commented May 24, 2024

Does this have tests?

@bakkot
Copy link

bakkot commented May 24, 2024

I couldn't find any existing tests to extend here, presumably due to #365. So I haven't written any tests for this. Happy to do so if there's a way to do it.

@saschanaz
Copy link
Member

saschanaz commented May 25, 2024

I'm against any significant extension without having a test coverage, but this one is small enough that I guess it's fine given the situation.

@marcoscaceres
Copy link
Member Author

We will at least get some limited testing just through the IDL interface. Sadly, most of Push is untested.

@saschanaz
Copy link
Member

Yeah, having some coverage here is in my wishlist. Anyway consider this comment as +1 from Mozilla.

@bakkot
Copy link

bakkot commented May 29, 2024

With a +1 from Mozilla and an implementation in Webkit is there anything blocking this from landing? Does it need a statement of non-opposition from Chrome?

@beverloo
Copy link
Member

We're happy with this, thank you! I'll try to get the change included in Chrome 128.

@marcoscaceres marcoscaceres merged commit a2f3730 into gh-pages May 30, 2024
2 checks passed
@marcoscaceres marcoscaceres deleted the bytes branch May 30, 2024 03:43
@marcoscaceres
Copy link
Member Author

@bakkot

Does it need a statement of non-opposition from Chrome?

That's correct 👍 It's part of WebApp's working mode. We are all about Team Web! 🥰

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jun 4, 2024
@marcoscaceres
Copy link
Member Author

implemented in Gecko, as per referenced Mozilla issue 🥳.

ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this pull request Jun 5, 2024
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants