Skip to content

Commit

Permalink
Some cleanups came up during another PR's review. (WICG#789)
Browse files Browse the repository at this point in the history
Also wrapped some very long lines.

Co-authored-by: Qingxin Wu <[email protected]>
  • Loading branch information
qingxinwu and Qingxin Wu authored Sep 14, 2023
1 parent 98b0b43 commit c277235
Showing 1 changed file with 51 additions and 31 deletions.
82 changes: 51 additions & 31 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ To <dfn>validate and convert auction ad config</dfn> given an {{AuctionAdConfig}
1. If |config|["{{AuctionAdConfig/auctionSignals}}"] [=map/exists=]:
1. Set |auctionConfig|'s [=auction config/auction signals=] to
|config|["{{AuctionAdConfig/auctionSignals}}"].
1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s [=auction config/auction signals=]:
1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s
[=auction config/auction signals=]:
* To parse the value |result|:
1. Let |auctionSignalsJSON| be the result of
[=serializing a JavaScript value to a JSON string=], given |result|.
Expand All @@ -910,14 +911,16 @@ To <dfn>validate and convert auction ad config</dfn> given an {{AuctionAdConfig}
1. If |config|["{{AuctionAdConfig/sellerSignals}}"] [=map/exists=]:
1. Set |auctionConfig|'s [=auction config/seller signals=] to
|config|["{{AuctionAdConfig/sellerSignals}}"].
1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s [=auction config/seller signals=]:
1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s
[=auction config/seller signals=]:
* To parse the value |result|:
1. Set |auctionConfig|'s [=auction config/seller signals=] to the result of
[=serializing a JavaScript value to a JSON string=], given |result|.
* To handle an error, set |auctionConfig|'s [=auction config/seller signals=] to failure.
1. If |config|["{{AuctionAdConfig/directFromSellerSignals}}"] [=map/exists=]:
1. TODO: The receiving end of this isn't specified yet, so there is no place to put the computed value.
1. [=Handle an input promise in configuration=] given |auctionConfig| and |config|["{{AuctionAdConfig/directFromSellerSignals}}"]:
1. [=Handle an input promise in configuration=] given |auctionConfig| and
|config|["{{AuctionAdConfig/directFromSellerSignals}}"]:
* To parse the value |result|:
1. Let |directFromSellerSignalsPrefix| be the result of running the [=URL parser=] on |result|.
1. [=exception/Throw=] a {{TypeError}} if any of the following conditions hold:
Expand Down Expand Up @@ -1430,7 +1433,8 @@ To <dfn>score and rank a bid</dfn> given an [=auction config=] |auctionConfig|,
<dt>{{ScoringBrowserSignals/interestGroupOwner}}
<dd>[=serialization of an origin|Serialized=] |owner|
<dt>{{ScoringBrowserSignals/renderURL}}
<dd>The result of running the [=URL serializer=] on |generatedBid|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=]
<dd>The result of running the [=URL serializer=] on |generatedBid|'s
[=generated bid/ad descriptor=]'s [=ad descriptor/url=]
<dt>{{ScoringBrowserSignals/biddingDurationMsec}}
<dd>|generatedBid|'s [=generated bid/bid duration=]
<dt>{{ScoringBrowserSignals/bidCurrency}}
Expand Down Expand Up @@ -1810,7 +1814,8 @@ To <dfn>round a value</dfn> given a {{double}} |value|:
1. If |value| is less than 0, return &minus;&infin;.
1. Otherwise, return &infin;.
1. Let |precisionScaledValue| be |normValue| multiplied by 256.
1. Let |noisyScaledValue| be |precisionScaledValue| plus a random {{double}} value greater than or equal to 0 but less than 1.
1. Let |noisyScaledValue| be |precisionScaledValue| plus a random {{double}} value greater than or
equal to 0 but less than 1.
1. Let |truncatedScaledValue| be the largest integer not greater than |noisyScaledValue|.
1. Return |truncatedScaledValue| multiplied by 2<sup>(|valueExp| &minus; 8)</sup>.

Expand Down Expand Up @@ -1883,7 +1888,9 @@ null |winningComponentConfig|:
<dd>|leadingBidInfo|'s [=leading bid info/scoring data version=] if it is not null,
{{undefined}} otherwise
</dl>
1. Let |igAd| be the [=interest group ad=] from |winner|'s [=generated bid/interest group=]'s [=interest group/ads=] whose [=interest group ad/render url=] is |winner|'s [=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. Let |igAd| be the [=interest group ad=] from |winner|'s [=generated bid/interest group=]'s
[=interest group/ads=] whose [=interest group ad/render url=] is |winner|'s
[=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. If |igAd|'s [=interest group ad/buyer and seller reporting ID=]
[=map/exists=] and the result of [=query reporting ID k-anonymity count=]
given |winner|'s [=generated bid/interest group=] and |igAd| is true:
Expand Down Expand Up @@ -1949,10 +1956,13 @@ and a {{ReportingBrowserSignals}} |browserSignals|:
[=interest group ad/render url=] is |winner|'s
[=generated bid/ad descriptor=]'s [=ad descriptor/url=].
1. If |igAd|'s [=interest group ad/buyer and seller reporting ID=]
does not [=map/exist=] and the result of [=query reporting ID k-anonymity count=] given |winner|'s [=generated bid/interest group=] and |igAd| is true:
does not [=map/exist=] and the result of [=query reporting ID k-anonymity count=] given
|winner|'s [=generated bid/interest group=] and |igAd| is true:
1. If |igAd|'s [=interest group ad/buyer reporting ID=] [=map/exists=],
[=map/set=] |reportWinBrowserSignals|["{{ReportWinBrowserSignals/buyerReportingId}}"] to |igAd|'s [=interest group ad/buyer reporting ID=].
1. Otherwise, [=map/Set=] |reportWinBrowserSignals|["{{ReportWinBrowserSignals/interestGroupName}}"] to |winner|'s [=generated bid/interest group=] [=interest group/name=].
[=map/set=] |reportWinBrowserSignals|["{{ReportWinBrowserSignals/buyerReportingId}}"] to
|igAd|'s [=interest group ad/buyer reporting ID=].
1. Otherwise, [=map/Set=] |reportWinBrowserSignals|["{{ReportWinBrowserSignals/interestGroupName}}"]
to |winner|'s [=generated bid/interest group=] [=interest group/name=].
1. Let |buyerReportingScript| be the result of [=fetching script=] with |winner|'s
[=generated bid/interest group=]'s [=interest group/bidding url=].
1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap| » be the result of
Expand Down Expand Up @@ -2022,7 +2032,8 @@ threshold when responding to [=query k-anonymity count=].
</div>

<div algorithm>
To <dfn>compute the key hash of reporting ID</dfn> given an [=interest group=] |ig| and an [=interest group ad=] |igAd|:
To <dfn>compute the key hash of reporting ID</dfn> given an [=interest group=] |ig| and an
[=interest group ad=] |igAd|:
1. Let |keyString| be the [=string/concatenation=] of the following strings separated with U+000A (LF):

1. "NameReport"
Expand Down Expand Up @@ -2101,7 +2112,8 @@ threshold when responding to [=query k-anonymity count=].
<div algorithm>
To <dfn>increment reporting ID k-anonymity count</dfn> given an [=interest group=] |ig| and a [=URL=]
|ad|:
1. Let |igAd| be the [=interest group ad=] from |ig|'s [=interest group/ads=] whose [=interest group ad/render url=] is |ad|.
1. Let |igAd| be the [=interest group ad=] from |ig|'s [=interest group/ads=] whose
[=interest group ad/render url=] is |ad|.
1. Let |keyHash| be the result of [=computing the key hash of reporting ID=] given |ig| and |igAd|.
1. [=Increment k-anonymity count=] given |keyHash|.
</div>
Expand Down Expand Up @@ -2260,7 +2272,8 @@ of the following global objects:
1. If no exception was [=exception/thrown=] in the previous step:
1. Set |generatedBid| to the result of [=converting GenerateBidOutput to generated bid=] with |generatedBidIDL|, |ig|, |expectedCurrency|, |isComponentAuction|, and |global|'s [=InterestGroupBiddingScriptRunnerGlobalScope/group has ad components=].
1. Otherwise, set |generatedBid| to failure.
1. If |generatedBid| is a [=generated bid=] and |generatedBid|'s [=generated bid/bid=]'s [=bid with currency/value=] &le; 0, set |generatedBid| to failure.
1. If |generatedBid| is a [=generated bid=] and |generatedBid|'s [=generated bid/bid=]'s
[=bid with currency/value=] &le; 0, set |generatedBid| to failure.
1. If |generatedBid| is null, set it to failure.
1. If |generatedBid| is not failure:
1. Set |generatedBid|'s [=generated bid/bid duration=] to |duration|.
Expand Down Expand Up @@ -2505,16 +2518,22 @@ To <dfn>convert GenerateBidOutput to generated bid</dfn> given a {{GenerateBidOu
1. Let |position| be a [=string/position variable=], initially pointing at the start of |input|.
1. [=Strip leading and trailing ASCII whitespace=] from |input|.
1. If |input| [=string/starts with=] "`0`" but [=string/is=] not "`0`" and does not
[=string/start with=] "`0.`", then return null as the dimension and the empty string as the dimension unit.
1. [=Collect a sequence of code points=] that are [=ASCII digits=] or U+002E (.), given |position|. Let that be |dimensionString|.
1. If |dimensionString| is the empty string, then return null as the dimension and the empty string as the dimension unit.
1. Let |dimension| be the result of parsing |dimensionString| using the [=rules for parsing floating-point number values=].
[=string/start with=] "`0.`", then return null as the dimension and the empty string as the
dimension unit.
1. [=Collect a sequence of code points=] that are [=ASCII digits=] or U+002E (.), given |position|.
Let that be |dimensionString|.
1. If |dimensionString| is the empty string, then return null as the dimension and the empty
string as the dimension unit.
1. Let |dimension| be the result of parsing |dimensionString| using the
[=rules for parsing floating-point number values=].
1. If |dimension| is an error, then return null as the dimension and the empty string as the dimension unit.
1. [=Collect a sequence of code points=] that are [=ASCII lower alpha=], given |position|. Let that be |dimensionUnit|.
1. If |position| is not past the end of |input|, then return null as the dimension and the empty string as the dimension unit.
1. [=Collect a sequence of code points=] that are [=ASCII lower alpha=], given |position|. Let
that be |dimensionUnit|.
1. If |position| is not past the end of |input|, then return null as the dimension and the empty
string as the dimension unit.
1. If |dimensionUnit| [=string/is=] the empty string, then set |dimensionUnit| to "px".
1. If |dimensionUnit| [=string/is=] not "px", "sh", or "sw", then return null as the dimension and the empty string as the
dimension unit.
1. If |dimensionUnit| [=string/is=] not "px", "sh", or "sw", then return null as the dimension and
the empty string as the dimension unit.
1. Return |dimension| as the dimension and |dimensionUnit| as the dimension unit.
</div>

Expand Down Expand Up @@ -2905,7 +2924,6 @@ Issue(WICG/turtledove#522): Move from "`*`" to "`self`".
# Structures # {#structures}

<xmp class="idl">

dictionary PreviousWin {
required long long timeDelta;
required DOMString adJSON;
Expand Down Expand Up @@ -2941,7 +2959,6 @@ Note: {{ScoringBrowserSignals}}'s {{ScoringBrowserSignals/adComponents}} is {{un
an [=list/is empty|empty list=].

<xmp class="idl">

dictionary ReportingBrowserSignals {
required DOMString topWindowHostname;
required USVString interestGroupOwner;
Expand Down Expand Up @@ -2987,7 +3004,6 @@ dictionary ReportingBrowserSignals {
</dl>

<xmp class="idl">

dictionary ReportResultBrowserSignals : ReportingBrowserSignals {
required double desirability;

Expand All @@ -3012,7 +3028,6 @@ dictionary ReportResultBrowserSignals : ReportingBrowserSignals {
</dl>

<xmp class="idl">

dictionary ReportWinBrowserSignals : ReportingBrowserSignals {
double adCost;
USVString seller;
Expand All @@ -3033,7 +3048,10 @@ dictionary ReportWinBrowserSignals : ReportingBrowserSignals {
<dd>True if the interest group owner was the only bidder that made bids with the second highest
score
<dt>{{ReportWinBrowserSignals/buyerReportingId}}
<dd>Set if the winning ad had a [=interest group ad/buyer reporting ID=] but not a [=interest group ad/buyer and seller reporting ID=] set in its listing in the interest group, and that value was [=query reporting ID k-anonymity count|jointly k-anonymous=] combined with interest group owner, bidding script URL, and ad creative URL.
<dd>Set if the winning ad had a [=interest group ad/buyer reporting ID=] but not a
[=interest group ad/buyer and seller reporting ID=] set in its listing in the interest group,
and that value was [=query reporting ID k-anonymity count|jointly k-anonymous=] combined with
interest group owner, bidding script URL, and ad creative URL.

<dt>{{ReportWinBrowserSignals/interestGroupName}}
<dd>Only set if the tuple of interest group owner, name, bidding script URL and ad creative URL
Expand Down Expand Up @@ -3224,22 +3242,22 @@ An auction config is a [=struct=] with the following items:
Owners of interest groups allowed to participate in the auction. Each [=origin's=] [=origin/scheme=]
must be "<code>https</code>".
: <dfn>auction signals</dfn>
:: Null or a [=string=] or a {{Promise}} or failure.
:: Null, a [=string=], a {{Promise}}, or failure.
Opaque JSON data passed to both sellers' and buyers' [=script runners=].
: <dfn>seller signals</dfn>
:: Null or a [=string=] or a {{Promise}} or failure.
:: Null, a [=string=], a {{Promise}}, or failure.
Opaque JSON data passed to the seller's [=script runner=].
: <dfn>seller timeout</dfn>
:: A [=duration=] in milliseconds, initially 50 milliseconds.
Restricts the runtime of the seller's `scoreAd()` script. If scoring does not complete before
the timeout, the bid being scored is not considered further.
: <dfn>per buyer signals</dfn>
:: Null or a {{Promise}} or failure or an [=ordered map=] whose [=map/keys=] are [=origins=] and
:: Null, a {{Promise}}, failure, or an [=ordered map=] whose [=map/keys=] are [=origins=] and
whose [=map/values=] are [=strings=].
[=map/Keys=] are buyers and must be valid HTTPS origins. [=map/Values=] are opaque JSON data
passed to corresponding buyer's [=script runner=].
: <dfn>per buyer timeouts</dfn>
:: Null or a {{Promise}} or failure or an [=ordered map=] whose [=map/keys=] are [=origins=] and
:: Null, a {{Promise}}, failure, or an [=ordered map=] whose [=map/keys=] are [=origins=] and
whose [=map/values=] are [=durations=] in milliseconds.
[=map/Keys=] are buyers and must be valid HTTPS origins. [=map/Values=] restrict the runtime of
corresponding buyer's `generateBid()` script. If the timeout expires, only the bid submitted
Expand Down Expand Up @@ -3331,7 +3349,8 @@ To <dfn>wait until configuration input promises resolve</dfn> given an [=auction
<div algorithm>
To <dfn>recursively wait until configuration input promises resolve</dfn> given an [=auction config=] |auctionConfig|:
1. [=list/For each=] |componentAuctionConfig| in |auctionConfig|'s [=auction config/component auctions=]:
1. If the result of [=waiting until configuration input promises resolve=] given |componentAuctionConfig| is failure, return failure.
1. If the result of [=waiting until configuration input promises resolve=] given
|componentAuctionConfig| is failure, return failure.
1. Return the result of [=waiting until configuration input promises resolve=] given |auctionConfig|.

</div>
Expand All @@ -3340,7 +3359,8 @@ To <dfn>recursively wait until configuration input promises resolve</dfn> given
To <dfn>handle an input promise in configuration</dfn> given an [=auction config=] |auctionConfig|,
a {{Promise}} |p|, and two sequences of steps, covering the parsing of the value and error-handling:
1. Increment |auctionConfig|'s [=auction config/pending promise count=].
1. Let |resolvedAndTypeChecked| be the promise representing performing the following steps [=upon fulfillment=] of |p| with |result|:
1. Let |resolvedAndTypeChecked| be the promise representing performing the following steps
[=upon fulfillment=] of |p| with |result|:
1. Execute the steps to be run for parsing of the value given |result|.
1. If no exception was [=exception/thrown=] in the previous step:
1. Decrement |auctionConfig|'s [=auction config/pending promise count=].
Expand Down

0 comments on commit c277235

Please sign in to comment.