Closed Bug 1826780 Opened 3 years ago Closed 2 years ago

Determine type of OPFS file objects

Categories

(Core :: DOM: File, task, P3)

task

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: jari, Assigned: jari)

References

(Blocks 1 open bug)

Details

Attachments

(6 files)

According to the getFile spec, type attribute of file objects is set to an implementation defined value.

Currently, OPFS is not setting it at all as it needs to be deduced from the name based on some rules.

Since type is already set for the other file objects, OPFS should presumably set the type using the same parsing mechanism.

Summary: Change FileSystemHandles to follow path semantics → Determine type of OPFS file objects

With the fix in bug 1825006 we hit FileBlobImpl::GetTypeInternal, but then fails to call the mime service because we are not in the worker nor in the main thread:

https://searchfox.org/mozilla-central/rev/9e3413f54ed6c9165b5659558091d766d34a731f/dom/file/FileBlobImpl.cpp#205

The potential fix is to get a non-worker Runnable and dispatch it to the main thread, but that can block this thread as this is synchronous. Does this sound good to you?

Flags: needinfo?(jjalkanen)
See Also: → 1825006

Another way is to do the same in MakeResolution(). I'd prefer that to be less obtrusive.

Flags: needinfo?(jjalkanen)

Yet another way is to not depend on the OS here, which sounds more ideal to me for this API.

Assignee: nobody → jjalkanen
Attachment #9328372 - Attachment description: WIP: Bug 1826780 - Use ContentType instead of nsString as OPFS file type. r=#dom-storage → Bug 1826780 - Use ContentType instead of nsString as OPFS file type. r=#dom-storage
Status: NEW → ASSIGNED
Attachment #9328373 - Attachment description: WIP: Bug 1826780 - Obtain content type from filename. r=#dom-storage → Bug 1826780 - Obtain content type from filename. r=#dom-storage
Attachment #9328374 - Attachment description: WIP: Bug 1826780 - Test content type of OPFS files. r=#dom-storage → Bug 1826780 - Test content type of OPFS files. r=#dom-storage
Pushed by jjalkanen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/93bc4e11ec3c Use ContentType instead of nsString as OPFS file type. r=dom-storage-reviewers,janv
Keywords: leave-open
Pushed by jjalkanen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f5b9f13d3aad Use ContentType instead of nsString as OPFS file type. r=dom-storage-reviewers,janv
Pushed by jjalkanen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e36ac535bad6 Interface with rust mime guess crate. r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/06078bc0975d Introduce content type guessing function. r=dom-storage-reviewers,janv https://hg.mozilla.org/integration/autoland/rev/8a64c9809f20 Obtain content type from filename. r=dom-storage-reviewers,janv https://hg.mozilla.org/integration/autoland/rev/d21bc1f962ff Support content type change on rename. r=dom-storage-reviewers,janv https://hg.mozilla.org/integration/autoland/rev/d6a5c60d7903 Test content type of OPFS files. r=dom-storage-reviewers,janv
Regressions: 1836459
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: