From feb9171bb454a1dcde084bd5074451a878348871 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Fri, 11 Oct 2024 10:30:09 -0400 Subject: [PATCH] Fix parsing of our promises to note they're nullable. (#1293) * Fix parsing of our promises to note they're nullable. * Propagate nulls further. * Actually set the nulls. --------- Co-authored-by: Maks Orlovich --- spec.bs | 104 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/spec.bs b/spec.bs index 83b0b674..a2286aed 100644 --- a/spec.bs +++ b/spec.bs @@ -704,16 +704,16 @@ dictionary AuctionAdConfig { sequence interestGroupBuyers; Promise auctionSignals; Promise sellerSignals; - Promise directFromSellerSignalsHeaderAdSlot; - Promise> deprecatedRenderURLReplacements; + Promise directFromSellerSignalsHeaderAdSlot; + Promise?> deprecatedRenderURLReplacements; unsigned long long sellerTimeout; unsigned short sellerExperimentGroupId; - Promise> perBuyerSignals; - Promise> perBuyerTimeouts; - Promise> perBuyerCumulativeTimeouts; + Promise?> perBuyerSignals; + Promise?> perBuyerTimeouts; + Promise?> perBuyerCumulativeTimeouts; unsigned long long reportingTimeout; USVString sellerCurrency; - Promise> perBuyerCurrencies; + Promise?> perBuyerCurrencies; record perBuyerMultiBidLimits; record perBuyerGroupLimits; record perBuyerExperimentGroupIds; @@ -1210,8 +1210,11 @@ To validate and convert auction ad config given an {{AuctionAdConfig} |config|["{{AuctionAdConfig/auctionSignals}}"]. 1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s [=auction config/auction signals=]: - * To parse the value |result|, set |auctionConfig|'s [=auction config/auction signals=] to the - result of [=serializing a JavaScript value to a JSON string=]. + * To parse the value |result|: + 1. If |result| is {{undefined}} or null, set |auctionConfig|'s [=auction config/auction + signals=] to null. + 1. Otherwise, set |auctionConfig|'s [=auction config/auction signals=] to the + result of [=serializing a JavaScript value to a JSON string=] given |result|. * To handle an error, set |auctionConfig|'s [=auction config/auction signals=] to failure. 1. If |config|["{{AuctionAdConfig/requestedSize}}"] [=map/exists=]: 1. Let |adSize| be the result from running [=parse an AdRender ad size=] with @@ -1236,8 +1239,11 @@ To validate and convert auction ad config given an {{AuctionAdConfig} |config|["{{AuctionAdConfig/sellerSignals}}"]. 1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s [=auction config/seller signals=]: - * To parse the value |result|, set |auctionConfig|'s [=auction config/seller signals=] to the - result of [=serializing a JavaScript value to a JSON string=], given |result|. + * To parse the value |result|: + 1. If |result| is {{undefined}} or null, set |auctionConfig|'s [=auction config/seller + signals=] to null. + 1. Otherwise, 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/auctionNonce}}"] [=map/exists=], then [=map/set=] |auctionConfig|'s [=auction config/auction nonce=] to the result of running [=get uuid from string=] with @@ -1313,10 +1319,11 @@ To validate and convert auction ad config given an {{AuctionAdConfig} [=auction config/deprecated render url replacements=]: * To parse the value |result|: 1. Let |renderUrlReplacements| be a new empty [=list=] of [=ad keyword replacement=]s. - 1. [=list/For each=] |replacement| in |result|: - 1. If [=validate a url macro=] with |replacement|'s [=ad keyword replacement/match=] - returns false, then [=exception/throw=] a {{TypeError}}. - 1. Otherwise, [=list/append=] |replacement| to |renderUrlReplacements|. + 1. If |result| is not null: + 1. [=list/For each=] |replacement| in |result|: + 1. If [=validate a url macro=] with |replacement|'s [=ad keyword replacement/match=] + returns false, then [=exception/throw=] a {{TypeError}}. + 1. Otherwise, [=list/append=] |replacement| to |renderUrlReplacements|. 1. Set |auctionConfig|'s [=auction config/deprecated render url replacements=] to |renderUrlReplacements|. * To handle an error, set |auctionConfig|'s @@ -1344,15 +1351,18 @@ To validate and convert auction ad config given an {{AuctionAdConfig} 1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s [=auction config/per buyer signals=]: * To parse the value |result|: - 1. Set |auctionConfig|'s [=auction config/per buyer signals=] to a new [=ordered map=] whose - [=map/keys=] are [=origins=] and whose [=map/values=] are [=strings=]. - 1. [=map/For each=] |key| → |value| of |result|: - 1. Let |buyer| be the result of [=parsing an https origin=] with |key|. If |buyer| is - failure, throw a {{TypeError}}. - 1. Let |signalsString| be the result of [=serializing a JavaScript value to a JSON string=], - given |value|. - 1. [=map/Set=] |auctionConfig|'s [=auction config/per buyer signals=][|buyer|] to - |signalsString|. + 1. If |result| is null: + 1. Set |auctionConfig|'s [=auction config/per buyer signals=] to null. + 1. Otherwise: + 1. Set |auctionConfig|'s [=auction config/per buyer signals=] to a new [=ordered map=] whose + [=map/keys=] are [=origins=] and whose [=map/values=] are [=strings=]. + 1. [=map/For each=] |key| → |value| of |result|: + 1. Let |buyer| be the result of [=parsing an https origin=] with |key|. If |buyer| is + failure, throw a {{TypeError}}. + 1. Let |signalsString| be the result of [=serializing a JavaScript value to a JSON + string=], given |value|. + 1. [=map/Set=] |auctionConfig|'s [=auction config/per buyer signals=][|buyer|] to + |signalsString|. * To handle an error, set |auctionConfig|'s [=auction config/per buyer signals=] to failure. 1. For each |idlTimeoutMember|, |perBuyerTimeoutField|, |allBuyersTimeoutField| in the following table @@ -1373,16 +1383,20 @@ To validate and convert auction ad config given an {{AuctionAdConfig} 1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s |perBuyerTimeoutField|: * To parse the value |result|: - 1. Set |auctionConfig|'s |perBuyerTimeoutField| to a new [=ordered map=] whose - [=map/keys=] are [=origins=] and whose [=map/values=] are [=durations=] in milliseconds. - 1. [=map/For each=] |key| → |value| of |result|: - 1. If |perBuyerTimeoutField| is "{{AuctionAdConfig/perBuyerTimeouts}}", and - |value| > 500, then set |value| to 500. - 1. If |key| is "*", then set |auctionConfig|'s |allBuyersTimeoutField| to |value| in - milliseconds, and [=iteration/continue=]. - 1. Let |buyer| be the result of [=parsing an https origin=] with |key|. If |buyer| is - failure, [=exception/throw=] a {{TypeError}}. - 1. [=map/Set=] |auctionConfig|'s |perBuyerTimeoutField|[|buyer|] to |value| in milliseconds. + 1. If |result| is null: + 1. Set |auctionConfig|'s |perBuyerTimeoutField| to null. + 1. Otherwise: + 1. Set |auctionConfig|'s |perBuyerTimeoutField| to a new [=ordered map=] whose + [=map/keys=] are [=origins=] and whose [=map/values=] are [=durations=] in milliseconds. + 1. [=map/For each=] |key| → |value| of |result|: + 1. If |perBuyerTimeoutField| is "{{AuctionAdConfig/perBuyerTimeouts}}", and + |value| > 500, then set |value| to 500. + 1. If |key| is "*", then set |auctionConfig|'s |allBuyersTimeoutField| to |value| in + milliseconds, and [=iteration/continue=]. + 1. Let |buyer| be the result of [=parsing an https origin=] with |key|. If |buyer| is + failure, [=exception/throw=] a {{TypeError}}. + 1. [=map/Set=] |auctionConfig|'s |perBuyerTimeoutField|[|buyer|] to |value| in + milliseconds. * To handle an error, set |auctionConfig|'s |perBuyerTimeoutField| to failure. 1. If |config|["{{AuctionAdConfig/perBuyerGroupLimits}}"] [=map/exists=], [=map/for each=] |key| → |value| of |config|["{{AuctionAdConfig/perBuyerGroupLimits}}"]: @@ -1435,16 +1449,20 @@ To validate and convert auction ad config given an {{AuctionAdConfig} 1. [=Handle an input promise in configuration=] given |auctionConfig| and |auctionConfig|'s [=auction config/per buyer currencies=]: * To parse the value |result|: - 1. Set |auctionConfig|'s [=auction config/per buyer currencies=] to a new [=ordered map=] - whose [=map/keys=] are [=origins=] and whose [=map/values=] are [=currency tags=]. - 1. [=map/for each=] |key| → |value| of |result|: - 1. If the result of [=checking whether a string is a valid currency tag=] given |value| is - false, [=exception/throw=] a {{TypeError}}. - 1. If |key| is "*", then set |auctionConfig|'s - [=auction config/all buyers currency=] to |value|, and [=iteration/continue=]. - 1. Let |buyer| be the result of [=parsing an https origin=] with |key|. If |buyer| is - failure, [=exception/throw=] a {{TypeError}}. - 1. [=map/Set=] |auctionConfig|'s [=auction config/per buyer currencies=][|buyer|] to |value|. + 1. If |result| is null: + 1. Set |auctionConfig|'s [=auction config/per buyer currencies=] to null. + 1. Otherwise: + 1. Set |auctionConfig|'s [=auction config/per buyer currencies=] to a new [=ordered map=] + whose [=map/keys=] are [=origins=] and whose [=map/values=] are [=currency tags=]. + 1. [=map/for each=] |key| → |value| of |result|: + 1. If the result of [=checking whether a string is a valid currency tag=] given |value| is + false, [=exception/throw=] a {{TypeError}}. + 1. If |key| is "*", then set |auctionConfig|'s + [=auction config/all buyers currency=] to |value|, and [=iteration/continue=]. + 1. Let |buyer| be the result of [=parsing an https origin=] with |key|. If |buyer| is + failure, [=exception/throw=] a {{TypeError}}. + 1. [=map/Set=] |auctionConfig|'s [=auction config/per buyer currencies=][|buyer|] to + |value|. * To handle an error, set |auctionConfig|'s [=auction config/per buyer currencies=] to failure. 1. If |config|["{{AuctionAdConfig/sellerRealTimeReportingConfig}}"] [=map/exists=]: 1. If |config|["{{AuctionAdConfig/sellerRealTimeReportingConfig}}"]["type"] is