diff --git a/testing/web-platform/tests/shared-storage/web-locks-pa-worklet-batch-update.tentative.https.window.js b/testing/web-platform/tests/shared-storage/web-locks-pa-worklet-batch-update.tentative.https.window.js new file mode 100644 index 000000000000..76d20fa59efe --- /dev/null +++ b/testing/web-platform/tests/shared-storage/web-locks-pa-worklet-batch-update.tentative.https.window.js @@ -0,0 +1,102 @@ + + + + + + + + + +"use strict;" + +subsetTest(promise_test, async test => { + let worklet = await sharedStorage.createWorklet('resources/simple-module.js'); + + const ancestor_key = token(); + let url0 = generateURL("/shared-storage/resources/frame0.html", + [ancestor_key]); + let url1 = generateURL("/shared-storage/resources/frame1.html", + [ancestor_key]); + + + + RESOURCE_PATH = '/fledge/tentative/resources/'; + + const pa_uuid = generateUuid(test); + + let biddingLogicURL = createBiddingScriptURL( + { + generateBid: + ` + sharedStorage.batchUpdate([ + new SharedStorageAppendMethod('key', 'a'), + new SharedStorageAppendMethod('key', 'a') + ], {withLock: 'lock1'}); + + return {}; + ` + }); + + let decisionLogicURL = createDecisionScriptURL(pa_uuid); + + + + + + + + + + + + + + + + + + + + + + + + + + + + let select_url_result = await worklet.selectURL( + "get-wait-set-within-lock", + [{url: url0}, {url: url1}], + {data: {'key': 'key', + 'lock_name': 'lock1', + 'append_letter': 'a'}, + resolveToConfig: true}); + + + const startWaitTime = Date.now(); + while (Date.now() - startWaitTime < 100) {} + + + + await joinGroupAndRunBasicFledgeTestExpectingNoWinner( + test, + { + uuid: pa_uuid, + interestGroupOverrides: { + name: pa_uuid, + biddingLogicURL: biddingLogicURL, + }, + auctionConfigOverrides: { + decisionLogicURL: decisionLogicURL + } + }); + + attachFencedFrame(select_url_result, 'opaque-ads'); + const result = await nextValueFromServer(ancestor_key); + assert_equals(result, "frame1_loaded"); + + await verifyKeyValueForOrigin('key', 'aaa', location.origin); + + await deleteKeyForOrigin('key', location.origin); +}, 'Test for batchUpdate() with a batch lock in a Protected Audience Worklet context');