Commit 17cdb147 authored by Andreas Haas's avatar Andreas Haas Committed by moz-wptsync-bot
Browse files

Bug 1721768 [wpt PR 29743] - [fsa] Implement getSize for the sync access handle, a=testonly

Automatic update from web-platform-tests
[fsa] Implement getSize for the sync access handle

The implementation is ported from the implementation of
Storage Foundation in
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/native_io/native_io_file_async.cc.

This is part of the efforts to merge Storage Foundation into OPFS.

Bug: chromium:1218431
Change-Id: I3c3fedf48b1e92e5dae019ef6c7b1db1fe9a81c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3043940


Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#904330}

--

wpt-commits: 6043ef9411ce8890aa2a5d4f1943576a4935c482
wpt-pr: 29743
parent 25ae711a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -61,4 +61,17 @@ sync_access_handle_test(async (testCase, handle) => {
  assert_equals(await closePromise, undefined);
}, 'SyncAccessHandle.flush fails immediately after calling SyncAccessHandle.close');


sync_access_handle_test(async (testCase, handle) => {
  assert_equals(await handle.close(), undefined);

  await promise_rejects_dom(testCase, 'InvalidStateError', handle.getSize());
}, 'SyncAccessHandle.getSize fails after SyncAccessHandle.close settles');

sync_access_handle_test(async (testCase, handle) => {
  const closePromise = handle.close();

  await promise_rejects_dom(testCase, 'InvalidStateError', handle.getSize());
  assert_equals(await closePromise, undefined);
}, 'SyncAccessHandle.getSize fails immediately after calling SyncAccessHandle.close');
done();
+26 −0
Original line number Diff line number Diff line
importScripts("/resources/testharness.js");
importScripts('resources/sync-access-handle-test.js');

'use strict';

sync_access_handle_test(async (testCase, handle) => {
  assert_equals(await handle.getSize(), 0);
  const bufferSize = 4;
  const writeBuffer = new Uint8Array(bufferSize);
  writeBuffer.set([96, 97, 98, 99]);
  handle.write(writeBuffer, {at: 0});
  assert_equals(await handle.getSize(), bufferSize);
  let offset = 3;
  handle.write(writeBuffer, {at: offset});
  assert_equals(await handle.getSize(), bufferSize + offset);
  offset = 10;
  handle.write(writeBuffer, {at: offset});
  assert_equals(await handle.getSize(), bufferSize + offset);
}, 'test SyncAccessHandle.getSize after SyncAccessHandle.write');

sync_access_handle_test(async (testCase, handle) => {
  const getSizePromise = handle.getSize();
  await promise_rejects_dom(testCase, 'InvalidStateError', handle.getSize());
  assert_equals(await getSizePromise, 0);
}, 'test createSyncAccessHandle.getSize with pending operation');
done();