forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bytes() to Blob and PushMessageData
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
- Loading branch information
Showing
15 changed files
with
123 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
PASS slice() | ||
PASS text() | ||
PASS arrayBuffer() | ||
PASS bytes() | ||
PASS stream() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
PASS Blob.bytes() | ||
PASS Blob.bytes() empty Blob data | ||
PASS Blob.bytes() non-ascii input | ||
PASS Blob.bytes() non-unicode input | ||
PASS Blob.bytes() concurrent reads | ||
|
1 change: 1 addition & 0 deletions
1
LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
45 changes: 45 additions & 0 deletions
45
LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// META: title=Blob bytes() | ||
// META: script=../support/Blob.js | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode("PASS"); | ||
const blob = new Blob([input_arr]); | ||
const uint8array = await blob.bytes(); | ||
assert_true(uint8array instanceof Uint8Array); | ||
assert_equals_typed_array(uint8array, input_arr); | ||
}, "Blob.bytes()") | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode(""); | ||
const blob = new Blob([input_arr]); | ||
const uint8array = await blob.bytes(); | ||
assert_true(uint8array instanceof Uint8Array); | ||
assert_equals_typed_array(uint8array, input_arr); | ||
}, "Blob.bytes() empty Blob data") | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode("\u08B8\u000a"); | ||
const blob = new Blob([input_arr]); | ||
const uint8array = await blob.bytes(); | ||
assert_equals_typed_array(uint8array, input_arr); | ||
}, "Blob.bytes() non-ascii input") | ||
|
||
promise_test(async () => { | ||
const input_arr = [8, 241, 48, 123, 151]; | ||
const typed_arr = new Uint8Array(input_arr); | ||
const blob = new Blob([typed_arr]); | ||
const uint8array = await blob.bytes(); | ||
assert_equals_typed_array(uint8array, typed_arr); | ||
}, "Blob.bytes() non-unicode input") | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode("PASS"); | ||
const blob = new Blob([input_arr]); | ||
const uint8array_results = await Promise.all([blob.bytes(), | ||
blob.bytes(), blob.bytes()]); | ||
for (let uint8array of uint8array_results) { | ||
assert_true(uint8array instanceof Uint8Array); | ||
assert_equals_typed_array(uint8array, input_arr); | ||
} | ||
}, "Blob.bytes() concurrent reads") |
7 changes: 7 additions & 0 deletions
7
LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.worker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
PASS Blob.bytes() | ||
PASS Blob.bytes() empty Blob data | ||
PASS Blob.bytes() non-ascii input | ||
PASS Blob.bytes() non-unicode input | ||
PASS Blob.bytes() concurrent reads | ||
|
1 change: 1 addition & 0 deletions
1
LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-bytes.any.worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters