diff --git a/spec.bs b/spec.bs index 649d35161..e36ce8441 100644 --- a/spec.bs +++ b/spec.bs @@ -1146,10 +1146,36 @@ To validate and convert auction ad config given an {{AuctionAdConfig} 1. If |seller| is failure, then return failure. 1. Set |auctionConfig|'s [=auction config/seller=] to |seller|. 1. If |config|["{{AuctionAdConfig/serverResponse}}"] [=map/exists=]: - 1. If |config|["{{AuctionAdConfig/requestId}}"] does not [=map/exist=], then [=exception/throw=] - a {{TypeError}}. - 1. Set |auctionConfig|'s [=auction config/server response=] to |config|["{{AuctionAdConfig/serverResponse}}"]. - 1. Set |auctionConfig|'s [=auction config/server response id=] to |config|["{{AuctionAdConfig/requestId}}"]. + 1. If |config|["{{AuctionAdConfig/requestId}}"] does not [=map/exist=], then [=exception/throw=] a + {{TypeError}}. + 1. Let |resolvedAndTypeChecked| be the promise representing performing the following steps + [=upon fulfillment=] of |config|["{{AuctionAdConfig/serverResponse}}"] with |result|: + 1. Set |auctionConfig|'s [=auction config/server response=] to the [=ArrayBuffer/transferred=] + |result|. + 1. Set |auctionConfig|'s [=auction config/server response id=] to + |config|["{{AuctionAdConfig/requestId}}"]. + 1. [=Upon rejection=] of |resolvedAndTypeChecked|: + 1. Set |auctionConfig|'s [=auction config/server response=] to failure. + + Note: The JavaScript code calling {{Navigator/runAdAuction()}} is responsible for *not* + resolving |config|["{{AuctionAdConfig/serverResponse}}"] until server responses have been + retrieved from one or more [:Ad-Auction-Result:] headers, as resolving this Promise early + would cause a race condition in which the [=script runners=] might run without the server + responses that it needs. There are two ways that server responses can be retrieved.
+ (1) The JavaScript code issues a [=request=] whose [=request/initiator type=] + is `"fetch"` and whose {{RequestInit/adAuctionHeaders}} option is set to `true`. The + JavaScript code has to resolve |config|["{{AuctionAdConfig/serverResponse}}"] after the + corresponding call to {{WindowOrWorkerGlobalScope/fetch()}} has resolved to a [=response=]. + The JavaScript code can also choose to wait to call {{Navigator/runAdAuction()}} until after + the corresponding call to {{WindowOrWorkerGlobalScope/fetch()}} has resolved to a [=response=], + and can then immediately resolve |config|["{{AuctionAdConfig/serverResponse}}"];
+ (2) issue an iframe navigation + request with the <{iframe/adauctionheaders}> content attribute set to `true`. + In this case, the JavaScript code is retrieved as part of the iframe navigation response, + at which point the JavaScript code in the iframe makes the call to + {{Navigator/runAdAuction()}}, and |config|["{{AuctionAdConfig/serverResponse}}"] can be + specified directly without a Promise. + 1. Otherwise: 1. If |config|["{{AuctionAdConfig/requestId}}"] [=map/exists=], then [=exception/throw=] a {{TypeError}}. @@ -1229,17 +1255,15 @@ To validate and convert auction ad config given an {{AuctionAdConfig} resolving |config|["{{AuctionAdConfig/additionalBids}}"] until additional bids have been retrieved from one or more [:Ad-Auction-Additional-Bid:] headers, as resolving this Promise early would cause a race condition in which additional bids might not be included in the - auction. There are two ways that additional bids can be retrieved. The first is for the - JavaScript code to issue a [=request=] whose [=request/initiator type=] is `"fetch"` and whose + auction. There are two ways that additional bids can be retrieved.
+ (1) The JavaScript code issues a [=request=] whose [=request/initiator type=] is `"fetch"` and whose {{RequestInit/adAuctionHeaders}} option is set to `true`. The JavaScript code has to resolve |config|["{{AuctionAdConfig/additionalBids}}"] after the corresponding call to {{WindowOrWorkerGlobalScope/fetch()}} has resolved to a [=response=]. The JavaScript code can also choose to wait to call {{Navigator/runAdAuction()}} until after the corresponding call to {{WindowOrWorkerGlobalScope/fetch()}} has resolved to a response, - and can then immediately resolve |config|["{{AuctionAdConfig/additionalBids}}"]. - - The second way that additional bids can be retrieved is by issuing an - iframe navigation + and can then immediately resolve |config|["{{AuctionAdConfig/additionalBids}}"];
+ (2) issue an iframe navigation request with the <{iframe/adauctionheaders}> content attribute set to `true`. In this case, the JavaScript code is retrieved as part of the iframe navigation response, at which point the JavaScript code in the iframe makes the call to @@ -1259,22 +1283,21 @@ To validate and convert auction ad config given an {{AuctionAdConfig} until direct from seller signals have been retrieved from one or more [:Ad-Auction-Signals:] headers, as resolving this Promise early would cause a race condition in which the [=script runners=] might run without the direct from seller signals that it needs. There are two ways that - direct from seller signals can be retrieved. The first is for the JavaScript code to issue a - [=request=] whose [=request/initiator type=] is `"fetch"` and whose + direct from seller signals can be retrieved.
+ (1) The JavaScript code issues a [=request=] whose [=request/initiator type=] is `"fetch"` and whose {{RequestInit/adAuctionHeaders}} option is set to `true`. The JavaScript code has to resolve |config|["{{AuctionAdConfig/directFromSellerSignalsHeaderAdSlot}}"] after the corresponding call to {{WindowOrWorkerGlobalScope/fetch()}} has resolved to a [=response=]. The JavaScript code can also choose to wait to call {{Navigator/runAdAuction()}} until after the corresponding call to {{WindowOrWorkerGlobalScope/fetch()}} has resolved to a [=response=], and can then immediately resolve - |config|["{{AuctionAdConfig/directFromSellerSignalsHeaderAdSlot}}"]. The second way that - direct from seller signals can be retrieved is by issuing an - iframe navigation + |config|["{{AuctionAdConfig/directFromSellerSignalsHeaderAdSlot}}"];
+ (2) issue an iframe navigation request with the <{iframe/adauctionheaders}> content attribute set to `true`. In this case, the JavaScript code is retrieved as part of the iframe navigation response, at which point the JavaScript code in the iframe makes the call to {{Navigator/runAdAuction()}}, and - |config|["{{AuctionAdConfig/directFromSellerSignalsHeaderAdSlot}}"] can be can be specified + |config|["{{AuctionAdConfig/directFromSellerSignalsHeaderAdSlot}}"] can be specified directly without a Promise. * To parse the value |result|: @@ -1676,14 +1699,15 @@ and a [=real time reporting contributions map=] |realTimeContributionsMap|: 1. [=list/For each=] |component| in |auctionConfig|'s [=auction config/component auctions=], [=parallel queue/enqueue steps|enqueue the following steps=] to |queue|: 1. If |component|'s [=auction config/server response=] is not null: - 1. Let |compWinnerInfo| be the result of running [=parse and validate server response=] with |component|, - |auctionConfig|, |global|, |bidIgs|, and |bidDebugReportInfoList|. + 1. Let |compWinnerInfo| be the result of running [=parse and validate server response=] with + |component|, |auctionConfig|, |global|, |bidIgs|, and |bidDebugReportInfoList|. 1. Otherwise: 1. Let |compWinnerInfo| be the result of running [=generate and score bids=] with |component|, |auctionConfig|, |global|, |bidIgs|, |bidDebugReportInfoList|, and |realTimeContributionsMap|. - 1. If |compWinnerInfo| is failure, abort these steps. - 1. If [=recursively wait until configuration input promises resolve=] given |auctionConfig| returns - failure, abort these steps. + 1. If [=recursively wait until configuration input promises resolve=] given |auctionConfig| + returns failure, or |compWinnerInfo| is failure, then: + 1. Decrement |pendingComponentAuctions| by 1. + 1. Abort these steps. 1. If |topLevelDirectFromSellerSignalsRetrieved| is false: 1. Let |topLevelDirectFromSellerSignals| be the result of running [=get direct from seller signals=] given |seller|, |auctionConfig|'s @@ -2784,6 +2808,8 @@ a [=list=] of [=interest groups=] |bidIgs|, and a [=list=] of [=bid debug report |bidDebugReportInfoList|, perform the following steps. They return a [=leading bid info=] or a failure. 1. [=Assert=] that these steps are running [=in parallel=]. +1. If [=waiting until server response promise resolves=] given |auctionConfig| returns failure, then + return failure. 1. Let |hash| be the [=SHA-256=] of |auctionConfig|'s [=auction config/server response=]. 1. Let |capturedAuctionHeaders| be |global|'s [=associated Document's=] [=node navigable's=] [=traversable navigable's=] [=traversable navigable/captured ad auction result headers=]. @@ -6521,6 +6547,16 @@ a {{Promise}} |p|, and two sequences of steps, covering the parsing of the value 1. Decrement |auctionConfig|'s [=auction config/pending promise count=]. +
+To wait until server response promise resolves given an [=auction config=] |auctionConfig|: + + 1. Wait until either |auctionConfig|'s [=auction config/server response=] is not a {{Promise}}, + or |auctionConfig|'s [=auction config/aborted=] is true. + 1. If |auctionConfig|'s [=auction config/aborted=] is true, return failure. + 1. If |auctionConfig|'s [=auction config/server response=] is failure, return failure. + 1. Return. +
+
To look up per-buyer currency given an [=auction config=] |auctionConfig|, and an [=origin=] |buyer|: