Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#226 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
74/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
html, javascript
Domaine
web-dev

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
HTML
Étoiles
118
Forks
52
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de w3c/FileAPI

Toutes les issues de w3c/FileAPI

Issues similaires

Plus d'issues Web Dev

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.