Skip to content

Commit

Permalink
[M115] Use camelCase for enableDebugMode's debug key argument
Browse files Browse the repository at this point in the history
i.e. debug_key -> debugKey. This would align with the web platform
design principles: https://www.w3.org/TR/design-principles/#casing-rules

Note that this does not change the JSON key used in the eventual report.
This change is breaking, but code can be written to support both pre-
and post-fix browsers to avoid compatibility issues, e.g.:
```
privateAggregation.enableDebugMode({debug_key: 123n, debugKey: 123n});
```

(cherry picked from commit c542499)

Bug: 1416320
Change-Id: I87413ccccab985e784fe8c87c86acf7435307f3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4264741
Reviewed-by: Russ Hamilton <behamilton@google.com>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Reviewed-by: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: Nan Lin <linnan@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1149858}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4574539
Reviewed-by: Caleb Raitto <caraitto@chromium.org>
Reviewed-by: Cammie Smith Barnes <cammie@chromium.org>
Cr-Commit-Position: refs/branch-heads/5790@{#144}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
alexmturner authored and Chromium LUCI CQ committed May 30, 2023
1 parent c7ad670 commit 788efdd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions content/services/auction_worklet/bidder_worklet_unittest.cc
Expand Up @@ -6909,7 +6909,7 @@ TEST_F(BidderWorkletPrivateAggregationEnabledTest, GenerateBid) {
CreateGenerateBidScript(
R"({ad: "ad", bid:1, render:"https://response.test/" })",
/*extra_code=*/R"(
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
privateAggregation.contributeToHistogram({bucket: 123n, value: 45});
privateAggregation.contributeToHistogramOnEvent(
"reserved.win", {bucket: 234n, value: 56});
Expand Down Expand Up @@ -7201,7 +7201,7 @@ TEST_F(BidderWorkletPrivateAggregationEnabledTest, ReportWin) {

RunReportWinWithFunctionBodyExpectingResult(
R"(
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
privateAggregation.contributeToHistogram({bucket: 123n, value: 45});
privateAggregation.contributeToHistogramOnEvent(
"reserved.win", {bucket: 234n, value: 56});
Expand Down
8 changes: 4 additions & 4 deletions content/services/auction_worklet/context_recycler_unittest.cc
Expand Up @@ -1272,7 +1272,7 @@ class ContextRecyclerPrivateAggregationEnabledTest
template <typename T>
v8::Local<v8::Value> WrapDebugKey(T debug_key) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(helper_->isolate());
dict.Set("debug_key", debug_key);
dict.Set("debugKey", debug_key);
return gin::ConvertToV8(helper_->isolate(), dict);
}

Expand Down Expand Up @@ -1671,8 +1671,8 @@ TEST_F(ContextRecyclerPrivateAggregationEnabledTest,
// Passing BigInts in directly is complicated so we construct them from
// strings.
if (typeof arg.debug_key === "string") {
arg.debug_key = BigInt(arg.debug_key);
if (typeof arg.debugKey === "string") {
arg.debugKey = BigInt(arg.debugKey);
}
privateAggregation.enableDebugMode(arg);
}
Expand Down Expand Up @@ -1800,7 +1800,7 @@ TEST_F(ContextRecyclerPrivateAggregationEnabledTest,
EXPECT_THAT(
error_msgs,
ElementsAre("https://example.org/script.js:21 Uncaught TypeError: "
"debug_key must be a BigInt."));
"debugKey must be a BigInt."));

EXPECT_TRUE(context_recycler.private_aggregation_bindings()
->TakePrivateAggregationRequests()
Expand Down
4 changes: 2 additions & 2 deletions content/services/auction_worklet/seller_worklet_unittest.cc
Expand Up @@ -4744,7 +4744,7 @@ TEST_F(SellerWorkletPrivateAggregationEnabledTest, ScoreAd) {
RunScoreAdWithJavascriptExpectingResult(
CreateScoreAdScript("5",
R"(
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
privateAggregation.contributeToHistogram({bucket: 123n, value: 45});
privateAggregation.contributeToHistogramOnEvent(
"reserved.win", {bucket: 234n, value: 56});
Expand Down Expand Up @@ -4973,7 +4973,7 @@ TEST_F(SellerWorkletPrivateAggregationEnabledTest, ReportResult) {
RunReportResultCreatedScriptExpectingResult(
"5",
R"(
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
privateAggregation.contributeToHistogram({bucket: 123n, value: 45});
)",
/*expected_signals_for_winner=*/"5",
Expand Down
5 changes: 3 additions & 2 deletions content/services/worklet_utils/private_aggregation_utils.cc
Expand Up @@ -67,7 +67,7 @@ absl::optional<uint64_t> ParseDebugKey(v8::Local<v8::Value> js_debug_key,
return absl::Uint128Low64(maybe_debug_key.value());
}

*error_out = "debug_key must be a BigInt";
*error_out = "debugKey must be a BigInt";
return absl::nullopt;
}

Expand Down Expand Up @@ -228,7 +228,8 @@ void ParseAndApplyEnableDebugModeArguments(
}

v8::Local<v8::Value> js_debug_key;
if (!dict.Get("debug_key", &js_debug_key)) {

if (!dict.Get("debugKey", &js_debug_key)) {
// Propagate any exception
return;
}
Expand Down
Expand Up @@ -150,7 +150,7 @@ void PrivateAggregation::enableDebugMode(
if (!maybe_debug_key || absl::Uint128High64(maybe_debug_key.value()) != 0) {
exception_state.ThrowDOMException(
DOMExceptionCode::kDataError,
"options['debug_key'] is negative or does not fit in 64 bits");
"options['debugKey'] is negative or does not fit in 64 bits");
return;
}

Expand Down
Expand Up @@ -3,5 +3,5 @@
// found in the LICENSE file.

dictionary PrivateAggregationDebugModeOptions {
required bigint debug_key;
required bigint debugKey;
};
Expand Up @@ -2962,7 +2962,7 @@ TEST_F(SharedStoragePrivateAggregationTest,
R"(
let error;
try {
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
privateAggregation.enableDebugMode();
} catch (e) {
error = e;
Expand Down Expand Up @@ -2994,7 +2994,7 @@ TEST_F(SharedStoragePrivateAggregationTest,
class EnableDebugMode {
async run() {
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
}
}
Expand Down Expand Up @@ -3032,7 +3032,7 @@ TEST_F(SharedStoragePrivateAggregationTest, MultipleDebugModeRequests) {
AddModuleResult add_module_result = AddModule(/*script_content=*/R"(
class TestClass {
async run() {
privateAggregation.enableDebugMode({debug_key: 1234n});
privateAggregation.enableDebugMode({debugKey: 1234n});
privateAggregation.contributeToHistogram({bucket: 1n, value: 2});
privateAggregation.contributeToHistogram({bucket: 3n, value: 4});
}
Expand Down

0 comments on commit 788efdd

Please sign in to comment.