1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/shared_storage/shared_storage_lock_manager.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/shared_storage_test_utils.h"
#include "content/public/test/test_renderer_host.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/shared_storage.mojom.h"
#include "third_party/blink/public/common/features.h"
namespace content {
namespace {
using AccessScope = blink::SharedStorageAccessScope;
class TestLockRequest : public blink::mojom::LockRequest {
public:
explicit TestLockRequest(
mojo::PendingAssociatedReceiver<blink::mojom::LockRequest> receiver)
: receiver_(this, std::move(receiver)) {}
// blink::mojom::LockRequest
void Granted(mojo::PendingAssociatedRemote<blink::mojom::LockHandle>
pending_handle) override {
granted_ = true;
handle_.Bind(std::move(pending_handle));
}
void Failed() override { failed_ = true; }
void ReleaseLock() {
CHECK(granted_);
handle_.reset();
}
bool granted() const { return granted_; }
bool failed() const { return failed_; }
private:
bool granted_ = false;
bool failed_ = false;
mojo::AssociatedRemote<blink::mojom::LockHandle> handle_;
mojo::AssociatedReceiver<blink::mojom::LockRequest> receiver_{this};
};
} // namespace
// Test `SharedStorageLockManager`. Since `BindLockManager()` delegates to
// `LockManager::BindReceiver()`, we avoid retesting this function alone.
// Rather, we focus on testing other functions and their interactions with
// `BindLockManager()`.
class SharedStorageLockManagerTest : public RenderViewHostTestHarness {
public:
SharedStorageLockManagerTest() {
web_locks_feature_.InitAndEnableFeature(
blink::features::kSharedStorageWebLocks);
transactional_batch_update_feature_.InitAndEnableFeature(
network::features::kSharedStorageTransactionalBatchUpdate);
}
void SetUp() override {
RenderViewHostTestHarness::SetUp();
test_lock_manager_ =
std::make_unique<SharedStorageLockManager>(StoragePartition());
}
void TearDown() override {
test_lock_manager_.reset();
content::RenderViewHostTestHarness::TearDown();
}
StoragePartitionImpl& StoragePartition() {
return *static_cast<StoragePartitionImpl*>(
web_contents()->GetBrowserContext()->GetDefaultStoragePartition());
}
void CreateExternalLockRequest1(
const url::Origin& origin,
const std::string& lock_name,
blink::mojom::LockMode lock_mode,
blink::mojom::LockManager::WaitMode wait_mode) {
CreateExternalLockRequestHelper(origin, lock_name, lock_mode, wait_mode,
/*request_number=*/1);
}
void CreateExternalLockRequest2(
const url::Origin& origin,
const std::string& lock_name,
blink::mojom::LockMode lock_mode,
blink::mojom::LockManager::WaitMode wait_mode) {
CreateExternalLockRequestHelper(origin, lock_name, lock_mode, wait_mode,
/*request_number=*/2);
}
std::u16string SharedStorageGet(const url::Origin& origin,
const std::u16string& key) {
base::test::TestFuture<storage::SharedStorageManager::GetResult> future;
StoragePartition().GetSharedStorageManager()->Get(origin, key,
future.GetCallback());
return future.Take().data;
}
protected:
std::unique_ptr<SharedStorageLockManager> test_lock_manager_;
std::unique_ptr<TestLockRequest> external_lock_request1_;
std::unique_ptr<TestLockRequest> external_lock_request2_;
base::test::ScopedFeatureList web_locks_feature_;
base::test::ScopedFeatureList transactional_batch_update_feature_;
private:
void CreateExternalLockRequestHelper(
const url::Origin& origin,
const std::string& lock_name,
blink::mojom::LockMode lock_mode,
blink::mojom::LockManager::WaitMode wait_mode,
size_t request_number) {
DCHECK(request_number == 1 || request_number == 2);
mojo::Remote<blink::mojom::LockManager>& external_lock_manager =
(request_number == 1) ? external_lock_manager1_
: external_lock_manager2_;
std::unique_ptr<TestLockRequest>& external_lock_request =
(request_number == 1) ? external_lock_request1_
: external_lock_request2_;
DCHECK(!external_lock_manager);
DCHECK(!external_lock_request);
mojo::PendingRemote<blink::mojom::LockManager> pending_lock_manager;
test_lock_manager_->BindLockManager(
origin, pending_lock_manager.InitWithNewPipeAndPassReceiver());
external_lock_manager.Bind(std::move(pending_lock_manager));
mojo::PendingAssociatedReceiver<blink::mojom::LockRequest>
lock_request_receiver;
mojo::PendingAssociatedRemote<blink::mojom::LockRequest>
lock_request_remote =
lock_request_receiver.InitWithNewEndpointAndPassRemote();
external_lock_request =
std::make_unique<TestLockRequest>(std::move(lock_request_receiver));
external_lock_manager->RequestLock(lock_name, lock_mode, wait_mode,
std::move(lock_request_remote));
}
mojo::Remote<blink::mojom::LockManager> external_lock_manager1_;
mojo::Remote<blink::mojom::LockManager> external_lock_manager2_;
};
TEST_F(SharedStorageLockManagerTest,
SharedStorageUpdateWithLock_ImmediatelyHandled) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
auto method_with_options =
MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true, /*with_lock=*/"lock1");
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageUpdate(
std::move(method_with_options), origin,
AccessScope::kSharedStorageWorklet,
/*main_frame_id=*/GlobalRenderFrameHostId(), /*worklet_ordinal_id=*/0,
/*worklet_devtools_token=*/base::UnguessableToken::Create(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// There's no other outstanding lock request. Thus, the `SharedStorageUpdate`
// is immediately handled.
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
}
TEST_F(SharedStorageLockManagerTest,
SharedStorageUpdateWithLock_WaitForGranted) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
CreateExternalLockRequest1(origin, /*lock_name=*/"lock1",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::WAIT);
auto method_with_options =
MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true, /*with_lock=*/"lock1");
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageUpdate(
std::move(method_with_options), origin,
AccessScope::kSharedStorageWorklet,
/*main_frame_id=*/GlobalRenderFrameHostId(), /*worklet_ordinal_id=*/0,
/*worklet_devtools_token=*/base::UnguessableToken::Create(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// The external lock is granted but not yet released. The
// `SharedStorageUpdate()` request is still waiting.
EXPECT_TRUE(external_lock_request1_->granted());
EXPECT_FALSE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"");
// After the external lock is released, the `SharedStorageUpdate()` gets
// handled.
external_lock_request1_->ReleaseLock();
task_environment()->RunUntilIdle();
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
}
TEST_F(SharedStorageLockManagerTest,
SharedStorageUpdateWithoutLock_ImmediatelyHandled) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
CreateExternalLockRequest1(origin, /*lock_name=*/"lock1",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::WAIT);
auto method_with_options =
MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true, /*with_lock=*/std::nullopt);
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageUpdate(
std::move(method_with_options), origin,
AccessScope::kSharedStorageWorklet,
/*main_frame_id=*/GlobalRenderFrameHostId(), /*worklet_ordinal_id=*/0,
/*worklet_devtools_token=*/base::UnguessableToken::Create(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// The external lock is granted but not yet released. The
// `SharedStorageUpdate()` request has been handled, as it does not request
// the lock.
EXPECT_TRUE(external_lock_request1_->granted());
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
}
TEST_F(SharedStorageLockManagerTest,
SharedStorageUpdateWithLock_BlockingExternalLockRequest) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
auto method_with_options =
MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true, /*with_lock=*/"lock1");
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageUpdate(
std::move(method_with_options), origin,
AccessScope::kSharedStorageWorklet,
/*main_frame_id=*/GlobalRenderFrameHostId(), /*worklet_ordinal_id=*/0,
/*worklet_devtools_token=*/base::UnguessableToken::Create(),
error_message_future.GetCallback());
EXPECT_FALSE(error_message_future.IsReady());
// Create an external lock request with WaitMode::NO_WAIT when the lock for
// `SharedStorageUpdate` is not yet released. The second request is expected
// to fail.
CreateExternalLockRequest1(origin, /*lock_name=*/"lock1",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::NO_WAIT);
task_environment()->RunUntilIdle();
EXPECT_TRUE(external_lock_request1_->failed());
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
}
TEST_F(SharedStorageLockManagerTest, BatchUpdateWithLock_ImmediatelyHandled) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods_with_options;
methods_with_options.push_back(MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true));
methods_with_options.push_back(MojomSetMethod(/*key=*/u"c", /*value=*/u"d",
/*ignore_if_present=*/true));
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageBatchUpdate(
std::move(methods_with_options),
/*with_lock=*/"lock1", origin, AccessScope::kWindow,
/*main_frame_id=*/GlobalRenderFrameHostId(),
/*worklet_ordinal_id=*/std::nullopt,
/*worklet_devtools_token=*/base::UnguessableToken::Null(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// There's no other outstanding lock request. Thus, the
// `SharedStorageBatchUpdate` is immediately handled.
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
}
TEST_F(SharedStorageLockManagerTest, BatchUpdateWithLock_WaitForGranted) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
CreateExternalLockRequest1(origin, /*lock_name=*/"lock1",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::WAIT);
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods_with_options;
methods_with_options.push_back(MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true));
methods_with_options.push_back(MojomSetMethod(/*key=*/u"c", /*value=*/u"d",
/*ignore_if_present=*/true));
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageBatchUpdate(
std::move(methods_with_options),
/*with_lock=*/"lock1", origin, AccessScope::kWindow,
/*main_frame_id=*/GlobalRenderFrameHostId(),
/*worklet_ordinal_id=*/std::nullopt,
/*worklet_devtools_token=*/base::UnguessableToken::Null(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// The external lock is granted but not yet released. The
// `SharedStorageBatchUpdate()` request is still waiting.
EXPECT_TRUE(external_lock_request1_->granted());
EXPECT_FALSE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"");
// After the external lock is released, the `SharedStorageBatchUpdate()` gets
// handled.
external_lock_request1_->ReleaseLock();
task_environment()->RunUntilIdle();
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
}
class SharedStorageLockManagerTransactionalBatchUpdateDisabledTest
: public SharedStorageLockManagerTest {
public:
SharedStorageLockManagerTransactionalBatchUpdateDisabledTest() {
transactional_batch_update_feature_.Reset();
transactional_batch_update_feature_.InitAndDisableFeature(
network::features::kSharedStorageTransactionalBatchUpdate);
}
};
// Test `SharedStorageBatchUpdate` with two methods. The first method requests a
// lock and waits for it to be granted. The second method is handled first.
TEST_F(SharedStorageLockManagerTransactionalBatchUpdateDisabledTest,
BatchUpdate_FirstMethodLockWaitForGranted) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
CreateExternalLockRequest1(origin, /*lock_name=*/"lock1",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::WAIT);
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods_with_options;
methods_with_options.push_back(MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true,
/*with_lock=*/"lock1"));
methods_with_options.push_back(MojomSetMethod(/*key=*/u"c", /*value=*/u"d",
/*ignore_if_present=*/true));
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageBatchUpdate(
std::move(methods_with_options),
/*with_lock=*/std::nullopt, origin, AccessScope::kWindow,
/*main_frame_id=*/GlobalRenderFrameHostId(),
/*worklet_ordinal_id=*/std::nullopt,
/*worklet_devtools_token=*/base::UnguessableToken::Null(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// The external lock is granted but not yet released. The batch update hasn't
// completely finished, but the second method within the batch has finished.
EXPECT_TRUE(external_lock_request1_->granted());
EXPECT_FALSE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
// After the external lock is released, the first method within the batch
// gets handled.
external_lock_request1_->ReleaseLock();
task_environment()->RunUntilIdle();
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
}
// Test `SharedStorageBatchUpdate` with two methods, both requesting locks and
// waiting for them to be granted. The second method's lock is granted first,
// and thus the second method is handled first.
TEST_F(SharedStorageLockManagerTransactionalBatchUpdateDisabledTest,
BatchUpdate_SecondMethodLockGrantedFirst) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
CreateExternalLockRequest1(origin, /*lock_name=*/"lock1",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::WAIT);
CreateExternalLockRequest2(origin, /*lock_name=*/"lock2",
blink::mojom::LockMode::EXCLUSIVE,
blink::mojom::LockManager::WaitMode::WAIT);
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods_with_options;
methods_with_options.push_back(MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true,
/*with_lock=*/"lock1"));
methods_with_options.push_back(MojomSetMethod(/*key=*/u"c", /*value=*/u"d",
/*ignore_if_present=*/true,
/*with_lock=*/"lock2"));
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageBatchUpdate(
std::move(methods_with_options),
/*with_lock=*/std::nullopt, origin, AccessScope::kWindow,
/*main_frame_id=*/GlobalRenderFrameHostId(),
/*worklet_ordinal_id=*/std::nullopt,
/*worklet_devtools_token=*/base::UnguessableToken::Null(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// The external locks are granted but not yet released. None of the methods
// within the batch has finished.
EXPECT_TRUE(external_lock_request1_->granted());
EXPECT_TRUE(external_lock_request2_->granted());
EXPECT_FALSE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"");
// After the external 'lock2' is released, the batch update hasn't completely
// finished, but the second method within the batch has finished.
external_lock_request2_->ReleaseLock();
task_environment()->RunUntilIdle();
EXPECT_FALSE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
// After the external 'lock1' is released, the first method within the batch
// gets handled.
external_lock_request1_->ReleaseLock();
task_environment()->RunUntilIdle();
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_TRUE(error_message_future.Take().empty());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
}
TEST_F(SharedStorageLockManagerTransactionalBatchUpdateDisabledTest,
BatchUpdate_BatchLockSameWithInnerMethodLock_Deadlock) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods_with_options;
methods_with_options.push_back(MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true,
/*with_lock=*/"lock1"));
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageBatchUpdate(
std::move(methods_with_options),
/*with_lock=*/"lock1", origin, AccessScope::kWindow,
/*main_frame_id=*/GlobalRenderFrameHostId(),
/*worklet_ordinal_id=*/std::nullopt,
/*worklet_devtools_token=*/base::UnguessableToken::Null(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// The batch lock is blocking the inner method lock, but the batch lock won't
// be released until the inner method gets handled. A deadlock has occurred.
// Note that this is a user-level error.
EXPECT_FALSE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"");
}
TEST_F(SharedStorageLockManagerTransactionalBatchUpdateDisabledTest,
BatchUpdate_TwoInnerMethodsWithSameLock_ImmediatelyHandled) {
url::Origin origin = url::Origin::Create(GURL("https://foo.com"));
std::vector<network::mojom::SharedStorageModifierMethodWithOptionsPtr>
methods_with_options;
methods_with_options.push_back(MojomSetMethod(/*key=*/u"a", /*value=*/u"b",
/*ignore_if_present=*/true,
/*with_lock=*/"lock1"));
methods_with_options.push_back(MojomSetMethod(/*key=*/u"c", /*value=*/u"d",
/*ignore_if_present=*/true,
/*with_lock=*/"lock1"));
base::test::TestFuture<const std::string&> error_message_future;
test_lock_manager_->SharedStorageBatchUpdate(
std::move(methods_with_options),
/*with_lock=*/std::nullopt, origin, AccessScope::kWindow,
/*main_frame_id=*/GlobalRenderFrameHostId(),
/*worklet_ordinal_id=*/std::nullopt,
/*worklet_devtools_token=*/base::UnguessableToken::Null(),
error_message_future.GetCallback());
task_environment()->RunUntilIdle();
// Each method acquires and releases the lock internally. The batch update
// finishes immediately.
EXPECT_TRUE(error_message_future.IsReady());
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"a"), u"b");
EXPECT_EQ(SharedStorageGet(origin, /*key=*/u"c"), u"d");
}
} // namespace content
|