mdn / browser-compat-data

This repository contains compatibility data for Web technologies as displayed on MDN
https://developer.mozilla.org
Creative Commons Zero v1.0 Universal
4.96k stars 1.99k forks source link

api.FileSystemFileHandle - Safari 15.2 does not work according to the spec while Chrome 108 does #18512

Open achu-topshelf opened 1 year ago

achu-topshelf commented 1 year ago

What type of issue is this?

Incorrect support data (ex. Chrome says "86" but support was added in "40")

What information was incorrect, unhelpful, or incomplete?

The following sequence works perfectly according to the spec in Chrome-108: In safari the following are the deviations from the compatibility guide. const fileSize = accessHandle.getSize() always return 0 const readSize = accessHandle.read(readBuffer, { "at": 0 }); always returns 0s accessHandle.write(writeBuffer, { "at" : 0 }); Not sure whether this writes anything

What browsers does this problem apply to, if applicable?

Safari

What did you expect to see?

The snippet described below works fine in Chrome-108. Expect the same from Safari 15.2 as claimed in the doc

Did you test this? If so, how?

The following sequence works perfectly according to the spec in Chrome-108: const fileHandle = await gFsRoot.getFileHandle("f1.txt"); const accessHandle = await fileHandle.createSyncAccessHandle(); const fileSize = accessHandle.getSize(); const readBuffer = new DataView(new ArrayBuffer(fileSize)); const readSize = accessHandle.read(readBuffer, { "at": 0 }); accessHandle.close(); In Safari 15.2, MacOS Monterey the following are the deviations from what is claimed in the compatibility report:

  1. accessHandle.getSize() returns a Promise is not a sync interface like in Chrome-108. Even if we wait for the reolution using await, the above always returns 0.
  2. Even if we pass the correct fileSize (based on what we wrote), accessHandle.read() always returns 0s.
  3. Not sure whether the following snippet actually writes the file in Safari (chrome-108 works fine). I do not see any errors and it fails silently in Safari probably. gFsRoot = await navigator.storage.getDirectory(); const fileHandle = await gFsRoot.getFileHandle("f1.txt", { "create" : true }); const accessHandle = await fileHandle.createSyncAccessHandle(); const encoder = new TextEncoder(); const writeBuffer = encoder.encode("Thank you for reading this."); accessHandle.write(writeBuffer, { "at" : 0 }); accessHandle.flush();

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API#browser_compatibility

webkit bug: https://bugs.webkit.org/show_bug.cgi?id=247071 discussion: https://github.com/whatwg/fs/pull/55

Do you have anything more you want to share?

No response

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

MDN metadata

MDN page report details * Query: `api.FileSystemFileHandle` * Report started: 2023-01-03T02:55:18.611Z
baryosef-loops commented 1 year ago

hi @achu-topshelf! Did you find the problem or the solution? I also experiencing the same with Safari 16.3