FileSystemFileHandle-create-sync-access-handle.js (984B)
1 'use strict'; 2 3 // This script depends on the following scripts: 4 // /fs/resources/messaging-helpers.js 5 // /fs/resources/test-helpers.js 6 7 directory_test(async (t, root_dir) => { 8 const fileSystemType = getFileSystemType(); 9 assert_true( 10 fileSystemType == 'sandboxed' || fileSystemType == 'local', 11 'File system type should be sandboxed or local.'); 12 const expect_success = fileSystemType == 'sandboxed'; 13 14 const dedicated_worker = 15 create_dedicated_worker(t, kDedicatedWorkerMessageTarget); 16 const file_handle = 17 await root_dir.getFileHandle('sync-access-handle-file', {create: true}); 18 19 dedicated_worker.postMessage( 20 {type: 'create-sync-access-handle', file_handle}); 21 22 const event_watcher = new EventWatcher(t, dedicated_worker, 'message'); 23 const message_event = await event_watcher.wait_for('message'); 24 const response = message_event.data; 25 26 assert_equals(response.success, expect_success); 27 }, 'Attempt to create a sync access handle.');