Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Blob and File serialization steps drop the type attribute (all engines keep it; WPT asserts it)

Đang mở
#226 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
html, javascript
Lĩnh vực
web-dev

Hướng nghiên cứu

Read the Blob and File serialization and deserialization sections in the File API specification, then inspect WPT's compare_Blob in html/webappapis/structured-clone/structured-clone-battery-of-tests.js. Update the four algorithms to preserve type and verify the structured-clone, postMessage, and IndexedDB cases pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The serialization and deserialization steps for Blob and File don't carry the type attribute, but every engine keeps it and WPT asserts it.

What the spec says

Blob's serialization steps set serialized.[[SnapshotState]] and serialized.[[ByteSequence]], and the deserialization steps restore only those two. File's steps add [[Name]] and [[LastModified]]. None of the four algorithms mentions type, so read literally:

structuredClone(new Blob(["x"], { type: "text/plain" })).type   // "" by the spec text
structuredClone(new File(["x"], "a.txt", { type: "text/plain" })).type   // "" by the spec text

The same holds for postMessage, history.pushState, and IndexedDB's StructuredSerializeForStorage.

What engines do

All three keep the type ("text/plain" above):

  • Blink: V8ScriptValueSerializer::WriteDOMObject writes the blob's uuid, type and size (kBlobTag), and File's type with its other fields.
  • WebKit: SerializedScriptValue.cpp: CloneSerializer writes blob->type() after the URL (BlobTag) and file.type() (FileTag), and readFile passes the type to File::deserialize.
  • Gecko: StructuredCloneHolder.cpp: WriteBlob keeps a reference to the BlobImpl (which holds the content type), and ReadBlob wraps the same impl, so the type carries over.
Tests

WPT's compare_Blob (html/webappapis/structured-clone/structured-clone-battery-of-tests.js) asserts actual.type === input.type for every cloned Blob and File, across the structured-clone, postMessage and IndexedDB variants.

Proposal
  • Blob serialization steps: add "Set serialized.[[Type]] to the value of value's type attribute."
  • Blob deserialization steps: add "Initialize the value of value's type attribute to serialized.[[Type]]."
  • File serialization and deserialization steps: the same two steps.

Possibly related: #98 (whether a clone copies or references the data), which doesn't cover type.

Found while implementing structured serialization for Blob and File in Crane, a web platform engine, which keeps the type as the engines do.

Ngôn ngữ chính
HTML
Star
118
Fork
52
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của w3c/FileAPI

Tất cả issue của w3c/FileAPI

Issue tương tự

Thêm issue về Web Dev

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.