Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spec] Handle B&A server response promise #1285

Merged
merged 9 commits into from
Sep 30, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 54 additions & 18 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,38 @@ To <dfn>validate and convert auction ad config</dfn> 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=]
|config|["{{AuctionAdConfig/serverResponse}}"].
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved
1. Set |auctionConfig|'s [=auction config/server response id=] to
|config|["{{AuctionAdConfig/requestId}}"].
1. If no exception was [=exception/thrown=] in the previous step, then decrement
|auctionConfig|'s [=auction config/pending promise count=].
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved
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.<br />
(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}}"];<br />
(2) issue an <a spec="html" lt="navigate an iframe or frame">iframe navigation</a>
request with the <{iframe/adauctionheaders}> <a spec=html>content attribute</a> 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}}.
Expand Down Expand Up @@ -1229,17 +1257,15 @@ To <dfn>validate and convert auction ad config</dfn> 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.<br />
(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
<a spec="html" lt="navigate an iframe or frame">iframe navigation</a>
and can then immediately resolve |config|["{{AuctionAdConfig/additionalBids}}"];<br />
(2) issue an <a spec="html" lt="navigate an iframe or frame">iframe navigation</a>
request with the <{iframe/adauctionheaders}> <a spec=html>content attribute</a> 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
Expand All @@ -1259,22 +1285,21 @@ To <dfn>validate and convert auction ad config</dfn> 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.<br />
(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
<a spec="html" lt="navigate an iframe or frame">iframe navigation</a>
|config|["{{AuctionAdConfig/directFromSellerSignalsHeaderAdSlot}}"];<br />
(2) issue an <a spec="html" lt="navigate an iframe or frame">iframe navigation</a>
request with the <{iframe/adauctionheaders}> <a spec=html>content attribute</a> 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|:
Expand Down Expand Up @@ -1676,8 +1701,8 @@ 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|.
Expand Down Expand Up @@ -2784,6 +2809,7 @@ 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 [=wait until server response promise resolve=] returns failure, then return failure.
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved
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=].
Expand Down Expand Up @@ -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=].
</div>

<div algorithm>
To <dfn>wait until server response promise resolve</dfn> given an [=auction config=] |auctionConfig|:
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved

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.
</div>

<div algorithm>
To <dfn>look up per-buyer currency</dfn> given an [=auction config=] |auctionConfig|, and an
[=origin=] |buyer|:
Expand Down
Loading