Closed Bug 1823445 Opened 2 years ago Closed 1 year ago

FileSystemFileHandle.createWritable({keepExistingData: false}) not working as expected

Categories

(Core :: DOM: File, defect, P2)

Firefox 111
Desktop
Windows 10
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: geart, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0

Steps to reproduce:

async function testWrite(){

var dirhandle = await navigator.storage.getDirectory();
var fhandle = await dirhandle.getFileHandle('test.txt', { create: true });
var faccess = await fhandle.createWritable();
await faccess.write("abcdefghijklmnop");
await faccess.close();

fhandle = await dirhandle.getFileHandle('test.txt');
var faccess = await fhandle.createWritable({keepExistingData: false});
await faccess.write("12345");
await faccess.close();

var fhandle = await dirhandle.getFileHandle('test.txt');
var file = await fhandle.getFile();
var text = await file.text();
console.log('text:', text);

return text;

}

Actual results:

The result is "12345fghijklmnop"

Expected results:

The first string should not have been kept, and "12345" returned.
Also tested with Chrome: returns "12345" as expected

User agents:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0'
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'

Component: Untriaged → DOM: File
OS: Unspecified → Windows 10
Product: Firefox → Core
Hardware: Unspecified → Desktop
Blocks: OPFS
Flags: needinfo?(jjalkanen)
Summary: FileSystemFileHandle.createWritable({keepExistingData: false}) not wurking as expected → FileSystemFileHandle.createWritable({keepExistingData: false}) not working as expected
Depends on: 1824305
Status: UNCONFIRMED → NEW
Ever confirmed: true

This will be resolved after the stack of patches related to 1824305 go in.

Flags: needinfo?(jjalkanen)
Severity: -- → S3
Priority: -- → P2

Patches related to 1824305 have landed now.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.