summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tsc/dts/lib.dom.d.ts2
-rw-r--r--cli/tsc/dts/lib.webworker.d.ts2
-rw-r--r--ext/web/09_file.js26
-rw-r--r--ext/web/lib.deno_web.d.ts1
-rw-r--r--tests/wpt/runner/expectation.json12
5 files changed, 26 insertions, 17 deletions
diff --git a/cli/tsc/dts/lib.dom.d.ts b/cli/tsc/dts/lib.dom.d.ts
index f0af1798c..1fa8798cb 100644
--- a/cli/tsc/dts/lib.dom.d.ts
+++ b/cli/tsc/dts/lib.dom.d.ts
@@ -3121,6 +3121,8 @@ interface Blob {
readonly type: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
arrayBuffer(): Promise<ArrayBuffer>;
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) */
+ bytes(): Promise<Uint8Array>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
slice(start?: number, end?: number, contentType?: string): Blob;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
diff --git a/cli/tsc/dts/lib.webworker.d.ts b/cli/tsc/dts/lib.webworker.d.ts
index 7ffd63c4b..3f722c1b0 100644
--- a/cli/tsc/dts/lib.webworker.d.ts
+++ b/cli/tsc/dts/lib.webworker.d.ts
@@ -1007,6 +1007,8 @@ interface Blob {
readonly type: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
arrayBuffer(): Promise<ArrayBuffer>;
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) */
+ bytes(): Promise<Uint8Array>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
slice(start?: number, end?: number, contentType?: string): Blob;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
diff --git a/ext/web/09_file.js b/ext/web/09_file.js
index 482a14012..7c1d79ce3 100644
--- a/ext/web/09_file.js
+++ b/ext/web/09_file.js
@@ -387,14 +387,9 @@ class Blob {
}
/**
- * @returns {Promise<string>}
+ * @param {number} size
+ * @returns {Promise<Uint8Array>}
*/
- async text() {
- webidl.assertBranded(this, BlobPrototype);
- const buffer = await this.#u8Array(this.size);
- return core.decode(buffer);
- }
-
async #u8Array(size) {
const bytes = new Uint8Array(size);
const partIterator = toIterator(this[_parts]);
@@ -414,6 +409,15 @@ class Blob {
}
/**
+ * @returns {Promise<string>}
+ */
+ async text() {
+ webidl.assertBranded(this, BlobPrototype);
+ const buffer = await this.#u8Array(this.size);
+ return core.decode(buffer);
+ }
+
+ /**
* @returns {Promise<ArrayBuffer>}
*/
async arrayBuffer() {
@@ -422,6 +426,14 @@ class Blob {
return TypedArrayPrototypeGetBuffer(buf);
}
+ /**
+ * @returns {Promise<Uint8Array>}
+ */
+ async bytes() {
+ webidl.assertBranded(this, BlobPrototype);
+ return await this.#u8Array(this.size);
+ }
+
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
return inspect(
createFilteredInspectProxy({
diff --git a/ext/web/lib.deno_web.d.ts b/ext/web/lib.deno_web.d.ts
index 36c77ef81..2fdf1c880 100644
--- a/ext/web/lib.deno_web.d.ts
+++ b/ext/web/lib.deno_web.d.ts
@@ -533,6 +533,7 @@ declare interface Blob {
readonly size: number;
readonly type: string;
arrayBuffer(): Promise<ArrayBuffer>;
+ bytes(): Promise<Uint8Array>;
slice(start?: number, end?: number, contentType?: string): Blob;
stream(): ReadableStream<Uint8Array>;
text(): Promise<string>;
diff --git a/tests/wpt/runner/expectation.json b/tests/wpt/runner/expectation.json
index e80fbf922..74eef8159 100644
--- a/tests/wpt/runner/expectation.json
+++ b/tests/wpt/runner/expectation.json
@@ -10109,8 +10109,8 @@
"Blob-text.any.worker.html": true,
"Blob-in-worker.worker.html": true,
"Blob-constructor-dom.window.html": false,
- "Blob-bytes.any.html": false,
- "Blob-bytes.any.worker.html": false,
+ "Blob-bytes.any.html": true,
+ "Blob-bytes.any.worker.html": true,
"Blob-constructor-endings.html": false
},
"file": {
@@ -10183,9 +10183,6 @@
"filereader_result.any.worker.html": true
},
"idlharness.any.html": [
- "Blob interface: operation bytes()",
- "Blob interface: new Blob([\"TEST\"]) must inherit property \"bytes()\" with the proper type",
- "Blob interface: new File([\"myFileBits\"], \"myFileName\") must inherit property \"bytes()\" with the proper type",
"FileList interface: existence and properties of interface object",
"FileList interface object length",
"FileList interface object name",
@@ -10196,9 +10193,6 @@
"FileList interface: attribute length"
],
"idlharness.any.worker.html": [
- "Blob interface: operation bytes()",
- "Blob interface: new Blob([\"TEST\"]) must inherit property \"bytes()\" with the proper type",
- "Blob interface: new File([\"myFileBits\"], \"myFileName\") must inherit property \"bytes()\" with the proper type",
"FileList interface: existence and properties of interface object",
"FileList interface object length",
"FileList interface object name",
@@ -10220,7 +10214,6 @@
],
"FileReaderSync.worker.html": false,
"idlharness.worker.html": [
- "Blob interface: operation bytes()",
"FileList interface: existence and properties of interface object",
"FileList interface object length",
"FileList interface object name",
@@ -10265,7 +10258,6 @@
"Service worker test setup"
],
"idlharness.html": [
- "Blob interface: operation bytes()",
"FileList interface: existence and properties of interface object",
"FileList interface object length",
"FileList interface object name",