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

Fix a number of imprecisions in GenerateBidOutput handling: #664

Merged
merged 9 commits into from
Jul 12, 2023
43 changes: 17 additions & 26 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2141,11 +2141,9 @@ of the following global objects:
1. Let |generatedBidIDL| be the result of [=converted to an IDL value|converting=]
|result|'s \[[Value]] to a {{GenerateBidOutput}}.
1. If no exception was [=exception/thrown=] in the previous step:
1. Let |groupHasAdComponents| be true.
1. If |ig|'s [=interest group/ad components=] is null, set |groupHasAdComponents| be false.
1. Let |possibleGeneratedBid| be the result of [=converting GenerateBidOutput to generated bid=]
with |generatedBidIDL|, |ig|, |expectedCurrency|, |isComponentAuction|, and |groupHasAdComponents|.
1. If |possibleGeneratedBid| is not failure, set |generatedBid| to it.
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=] ≤ 0, set |generatedBid| to failure.
1. If |generatedBid| is null, set it to failure.
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved
1. If |generatedBid| is not failure:
1. Set |generatedBid|'s [=generated bid/bid duration=] to |duration|.
Expand Down Expand Up @@ -2261,26 +2259,25 @@ interface InterestGroupScriptRunnerGlobalScope {
InterestGroupBiddingScriptRunnerGlobalScope)]
interface InterestGroupBiddingScriptRunnerGlobalScope
: InterestGroupScriptRunnerGlobalScope {
boolean setBid();
boolean setBid(GenerateBidOutput generateBidOutput);
boolean setBid(optional GenerateBidOutput generateBidOutput = {});
undefined setPriority(double priority);
undefined setPrioritySignalsOverride(DOMString key, double priority);
};

dictionary AdRender {
required DOMString url;
required DOMString width;
required DOMString height;
DOMString width;
DOMString height;
};

dictionary GenerateBidOutput {
required double bid;
double bid = -1;
DOMString bidCurrency;
required (DOMString or AdRender) render;
(DOMString or AdRender) render;
any ad;
sequence<(DOMString or AdRender)> adComponents;
double adCost;
double modelingSignals;
unrestricted double modelingSignals;
morlovich marked this conversation as resolved.
Show resolved Hide resolved
boolean allowComponentAuction = false;
};

Expand All @@ -2305,24 +2302,20 @@ Each {{InterestGroupBiddingScriptRunnerGlobalScope}} has a

</dl>

<div algorithm>
The <dfn method for="InterestGroupBiddingScriptRunnerGlobalScope">setBid()</dfn> method steps are:

1. Set [=this=]'s [=relevant global object=]'s [=InterestGroupBiddingScriptRunnerGlobalScope/bid=]
to null.
1. Return true.
</div>

<div algorithm>

To <dfn>convert GenerateBidOutput to generated bid</dfn> given a {{GenerateBidOutput}}
|generateBidOutput|, an [=interest group=] |ig|, a [=currency tag=] |expectedCurrency|, a [=boolean=]
|isComponentAuction| and a [=boolean=] |groupHasAdComponents|:
1. If |generateBidOutput|["{{GenerateBidOutput/bid}}"] is less than or equal to 0, return failure.
qingxinwu marked this conversation as resolved.
Show resolved Hide resolved
1. Let |bid| be a new [=generated bid=].
1. If |generateBidOutput|["{{GenerateBidOutput/bid}}"] &le; 0:
1. Set |bid|'s [=generated bid/bid=] to a [=bid with currency=] with [=bid with currency/value=] |generateBidOutput|["{{GenerateBidOutput/bid}}"] and [=bid with currency/currency=] null.
1. Return |bid|.
1. If |generateBidOutput|["{{GenerateBidOutput/render}}"] does not [=map/exist=], return failure.
1. If |isComponentAuction| is true, and
|generateBidOutput|["{{GenerateBidOutput/allowComponentAuction}}"] is false:
1. Return failure.
1. Let |bid| be a new [=generated bid=].
1. Let |bidCurrency| be null.
1. If |generateBidOutput|["{{GenerateBidOutput/bidCurrency}}"] is specified:
1. If the result of [=checking whether a string is a valid currency tag=] on
Expand Down Expand Up @@ -2374,8 +2367,8 @@ To <dfn>convert GenerateBidOutput to generated bid</dfn> given a {{GenerateBidOu
|generateBidOutput|["{{GenerateBidOutput/adCost}}"].
1. If |generateBidOutput|["{{GenerateBidOutput/modelingSignals}}"] [=map/exists=]:
1. Let |modelingSignals| be |generateBidOutput|["{{GenerateBidOutput/modelingSignals}}"].
1. If |modelingSignals| is greater than or equal to 0 and less than 4096:
1. Set |bid|'s [=generated bid/modeling signals=] to |modelingSignals|.
1. If |modelingSignals| &ge; 0 and |modelingSignals| < 4096:
1. Set |bid|'s [=generated bid/modeling signals=] to the result of [=converted to an IDL value|converting=] the ECMAScript value represented by |modelingSignals| to an {{unsigned short}}.
1. Return |bid|.

</div>
Expand Down Expand Up @@ -2403,7 +2396,6 @@ To <dfn>convert GenerateBidOutput to generated bid</dfn> given a {{GenerateBidOu
To <dfn>convert an ad render</dfn> given an {{AdRender}} |adRender|, an [=interest group=] |ig|,
and a [=boolean=] |isComponent|:

1. If |adRender|["{{AdRender/url}}"] does not [=map/exist=], return false.
1. Let |adUrl| be the result of running the [=URL parser=] on |adRender|["{{AdRender/url}}"].
1. If |adUrl| is failure, return failure.
1. If [=validating an ad url=] given |adUrl|, |ig|, and |isComponent| returns false, return failure.
Expand Down Expand Up @@ -2453,10 +2445,9 @@ To <dfn>convert GenerateBidOutput to generated bid</dfn> given a {{GenerateBidOu
[=InterestGroupBiddingScriptRunnerGlobalScope/is component auction=], and [=this=]'s
[=relevant global object=]'s
[=InterestGroupBiddingScriptRunnerGlobalScope/group has ad components=].
1. If |bidToSet| is failure, return false.
1. If |bidToSet| is failure, [=exception/throw=] a {{TypeError}}.
1. Set [=this=]'s [=relevant global object=]'s [=InterestGroupBiddingScriptRunnerGlobalScope/bid=]
to |bidToSet|.
1. Return true.
</div>

<div algorithm>
Expand Down