0

Remove PrivacySandboxAdsAPIs OT code

This OT has been ended for over 7 months, and each of these APIs is
shipped. This cleans up all of the OT related code and tests.

Bug: 331926920
Change-Id: If634346099b99d8a029801cb65fd9ead20f08179
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5414474
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Russ Hamilton <behamilton@google.com>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Nan Lin <linnan@chromium.org>
Reviewed-by: Yao Xiao <yaoxia@chromium.org>
Commit-Queue: John Delaney <johnidel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1325080}
This commit is contained in:
John Delaney
2024-07-09 20:11:45 +00:00
committed by Chromium LUCI CQ
parent 910195b593
commit d8b4ba2d88
16 changed files with 22 additions and 711 deletions

@ -10,13 +10,11 @@
#include "components/attribution_reporting/features.h"
#include "content/browser/browsing_topics/test_util.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/features.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_switches.h"
@ -39,7 +37,7 @@
namespace content {
namespace {
constexpr char kBaseDataDir[] = "content/test/data/attribution_reporting/";
constexpr char kBaseDataDir[] = "content/test/data/";
constexpr char kAddFencedFrameScript[] = R"(
const fenced_frame = document.createElement('fencedframe');
@ -88,16 +86,6 @@ class PrivacySandboxAdsAPIsBrowserTestBase : public ContentBrowserTest {
url_loader_interceptor_ =
std::make_unique<URLLoaderInterceptor>(base::BindLambdaForTesting(
[&](URLLoaderInterceptor::RequestParams* params) -> bool {
last_request_is_topics_request_ =
params->url_request.browsing_topics;
last_topics_header_.reset();
std::string topics_header;
if (params->url_request.headers.GetHeader("Sec-Browsing-Topics",
&topics_header)) {
last_topics_header_ = topics_header;
}
URLLoaderInterceptor::WriteResponse(
base::StrCat(
{kBaseDataDir, params->url_request.url.path_piece()}),
@ -122,421 +110,12 @@ class PrivacySandboxAdsAPIsBrowserTestBase : public ContentBrowserTest {
.root();
}
bool last_request_is_topics_request() const {
return last_request_is_topics_request_;
}
const std::optional<std::string>& last_topics_header() const {
return last_topics_header_;
}
private:
bool last_request_is_topics_request_ = false;
std::optional<std::string> last_topics_header_;
std::unique_ptr<FixedTopicsContentBrowserClient> browser_client_;
std::unique_ptr<URLLoaderInterceptor> url_loader_interceptor_;
};
class PrivacySandboxAdsAPIsAllEnabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsAllEnabledBrowserTest() {
feature_list_.InitWithFeatures(
{blink::features::kPrivacySandboxAdsAPIs,
blink::features::kBrowsingTopics,
blink::features::kBrowsingTopicsDocumentAPI,
blink::features::kInterestGroupStorage, blink::features::kFencedFrames,
blink::features::kSharedStorageAPI},
/*disabled_features=*/{
network::features::kAttributionReportingCrossAppWeb,
features::kPrivacySandboxAdsAPIsM1Override});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsAllEnabledBrowserTest,
OriginTrialEnabled_FeatureDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"browsing-topics')"));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"join-ad-interest-group')"));
EXPECT_EQ(true, ExecJs(root(), "sharedStorage !== undefined"));
EXPECT_EQ(true, EvalJs(shell(), "document.browsingTopics !== undefined"));
EXPECT_EQ(true, EvalJs(shell(), "navigator.runAdAuction !== undefined"));
EXPECT_EQ(true,
EvalJs(shell(), "navigator.joinAdInterestGroup !== undefined"));
EXPECT_TRUE(ExecJs(root(), kAddFencedFrameScript));
EXPECT_EQ(1U, root()->child_count());
}
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsAllEnabledBrowserTest,
OriginTrialDisabled_FeatureNotDetected) {
// Navigate to a page without an OT token.
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_without_ads_apis_ot.html")));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"browsing-topics')"));
EXPECT_EQ(true, ExecJs(shell(), "window.sharedStorage === undefined"));
EXPECT_EQ(true, EvalJs(shell(), "document.browsingTopics === undefined"));
EXPECT_TRUE(ExecJs(root(), kAddFencedFrameScript));
EXPECT_EQ(0U, root()->child_count());
}
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsAllEnabledBrowserTest,
OriginTrialEnabled_TopicsAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace(
"fetch($1, {browsingTopics: true})",
GURL("https://example.test/page_without_ads_apis_ot.html"))));
EXPECT_TRUE(last_request_is_topics_request());
EXPECT_TRUE(last_topics_header());
EXPECT_EQ(last_topics_header().value(),
"(1);v=chrome.1:1:2, ();p=P00000000000");
}
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsAllEnabledBrowserTest,
OriginTrialDisabled_TopicsNotAllowedForFetch) {
// Navigate to a page without an OT token.
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_without_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace(
"fetch($1, {browsingTopics: true})",
GURL("https://example.test/page_without_ads_apis_ot.html"))));
EXPECT_FALSE(last_request_is_topics_request());
EXPECT_FALSE(last_topics_header());
}
IN_PROC_BROWSER_TEST_F(
PrivacySandboxAdsAPIsAllEnabledBrowserTest,
OriginTrialEnabled_HasBrowsingTopicsIframeAttr_ConsideredForEmbedderOptIn) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
// Wait for the iframe navigation.
IframeBrowsingTopicsAttributeWatcher navigation_observer(
shell()->web_contents());
ExecuteScriptAsync(shell()->web_contents(), R"(
const iframe = document.createElement("iframe");
iframe.browsingTopics = true;
iframe.src = 'https://example.test/page_without_ads_apis_ot.html';
document.body.appendChild(iframe);
)");
navigation_observer.WaitForNavigationFinished();
EXPECT_EQ(navigation_observer.last_navigation_url(),
"https://example.test/page_without_ads_apis_ot.html");
EXPECT_TRUE(navigation_observer
.last_navigation_has_iframe_browsing_topics_attribute());
}
IN_PROC_BROWSER_TEST_F(
PrivacySandboxAdsAPIsAllEnabledBrowserTest,
OriginTrialDisabled_HasBrowsingTopicsIframeAttr_NotConsideredForEmbedderOptIn) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_without_ads_apis_ot.html")));
// Wait for the iframe navigation.
IframeBrowsingTopicsAttributeWatcher navigation_observer(
shell()->web_contents());
ExecuteScriptAsync(shell()->web_contents(), R"(
const iframe = document.createElement("iframe");
iframe.browsingTopics = true;
iframe.src = 'https://example.test/page_without_ads_apis_ot.html';
document.body.appendChild(iframe);
)");
navigation_observer.WaitForNavigationFinished();
EXPECT_EQ(navigation_observer.last_navigation_url(),
"https://example.test/page_without_ads_apis_ot.html");
EXPECT_FALSE(navigation_observer
.last_navigation_has_iframe_browsing_topics_attribute());
}
class PrivacySandboxAdsAPIsTopicsDisabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsTopicsDisabledBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPrivacySandboxAdsAPIs,
blink::features::kBrowsingTopicsDocumentAPI},
/*disabled_features=*/{blink::features::kBrowsingTopics});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsTopicsDisabledBrowserTest,
OriginTrialEnabled_CorrectFeaturesDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"browsing-topics')"));
EXPECT_EQ(false, EvalJs(shell(), "document.browsingTopics !== undefined"));
}
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsTopicsDisabledBrowserTest,
OriginTrialEnabled_TopicsNotAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace(
"fetch($1, {browsingTopics: true})",
GURL("https://example.test/page_without_ads_apis_ot.html"))));
EXPECT_FALSE(last_request_is_topics_request());
EXPECT_FALSE(last_topics_header());
}
class PrivacySandboxAdsAPIsTopicsBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsTopicsBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPrivacySandboxAdsAPIs,
blink::features::kBrowsingTopics},
/*disabled_features=*/{});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsTopicsBrowserTest,
OriginTrialEnabled_TopicsFeatureDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"browsing-topics')"));
EXPECT_EQ(true, EvalJs(shell(), "document.browsingTopics !== undefined"));
}
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsTopicsBrowserTest,
OriginTrialEnabled_TopicsAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace(
"fetch($1, {browsingTopics: true})",
GURL("https://example.test/page_without_ads_apis_ot.html"))));
EXPECT_TRUE(last_request_is_topics_request());
EXPECT_TRUE(last_topics_header());
EXPECT_EQ(last_topics_header().value(),
"(1);v=chrome.1:1:2, ();p=P00000000000");
}
class PrivacySandboxAdsAPIsTopicsDocumentAPIDisabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsTopicsDocumentAPIDisabledBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPrivacySandboxAdsAPIs,
blink::features::kBrowsingTopics},
/*disabled_features=*/{blink::features::kBrowsingTopicsDocumentAPI});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(
PrivacySandboxAdsAPIsTopicsDocumentAPIDisabledBrowserTest,
OriginTrialEnabled_TopicsFeatureDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"browsing-topics')"));
}
IN_PROC_BROWSER_TEST_F(
PrivacySandboxAdsAPIsTopicsDocumentAPIDisabledBrowserTest,
OriginTrialEnabled_JavascriptAPIUndefined) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(), "document.browsingTopics === undefined"));
}
IN_PROC_BROWSER_TEST_F(
PrivacySandboxAdsAPIsTopicsDocumentAPIDisabledBrowserTest,
OriginTrialEnabled_TopicsAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace(
"fetch($1, {browsingTopics: true})",
GURL("https://example.test/page_without_ads_apis_ot.html"))));
EXPECT_TRUE(last_request_is_topics_request());
EXPECT_TRUE(last_topics_header());
EXPECT_EQ(last_topics_header().value(),
"(1);v=chrome.1:1:2, ();p=P00000000000");
}
class PrivacySandboxAdsAPIsSharedStorageDisabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsSharedStorageDisabledBrowserTest() {
feature_list_.InitWithFeatures({blink::features::kPrivacySandboxAdsAPIs},
{blink::features::kSharedStorageAPI});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsSharedStorageDisabledBrowserTest,
OriginTrialEnabled_CorrectFeaturesDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_EQ(true, ExecJs(shell(), "window.sharedStorage === undefined"));
}
class PrivacySandboxAdsAPIsFledgeDisabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsFledgeDisabledBrowserTest() {
feature_list_.InitWithFeatures({blink::features::kPrivacySandboxAdsAPIs},
{blink::features::kInterestGroupStorage});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsFledgeDisabledBrowserTest,
OriginTrialEnabled_CorrectFeaturesDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"join-ad-interest-group')"));
EXPECT_EQ(false, EvalJs(shell(), "navigator.runAdAuction !== undefined"));
EXPECT_EQ(false,
EvalJs(shell(), "navigator.joinAdInterestGroup !== undefined"));
}
class PrivacySandboxAdsAPIsFencedFramesDisabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsFencedFramesDisabledBrowserTest() {
feature_list_.InitWithFeatures({blink::features::kPrivacySandboxAdsAPIs},
{blink::features::kFencedFrames});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsFencedFramesDisabledBrowserTest,
OriginTrialEnabled_CorrectFeaturesDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_TRUE(ExecJs(root(), kAddFencedFrameScript));
EXPECT_EQ(0U, root()->child_count());
}
class PrivacySandboxAdsAPIsDisabledBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
PrivacySandboxAdsAPIsDisabledBrowserTest() {
feature_list_.InitWithFeatures(
{},
/*disabled_features=*/{
blink::features::kPrivacySandboxAdsAPIs,
network::features::kAttributionReportingCrossAppWeb,
features::kPrivacySandboxAdsAPIsM1Override});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsDisabledBrowserTest,
BaseFeatureDisabled_FeatureNotDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"attribution-reporting')"));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"
"browsing-topics')"));
EXPECT_EQ(true, ExecJs(shell(), "window.sharedStorage === undefined"));
EXPECT_EQ(true, EvalJs(shell(), "document.browsingTopics === undefined"));
EXPECT_TRUE(ExecJs(root(), kAddFencedFrameScript));
EXPECT_EQ(0U, root()->child_count());
}
class PrivacySandboxAdsAPIsM1OverrideBrowserTest
: public PrivacySandboxAdsAPIsBrowserTestBase {
public:
@ -556,8 +135,7 @@ class PrivacySandboxAdsAPIsM1OverrideBrowserTest
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsM1OverrideBrowserTest,
NoOT_FeatureDetected) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_without_ads_apis_ot.html")));
EXPECT_TRUE(NavigateToURL(shell(), GURL("https://example.test/title1.html")));
EXPECT_EQ(true, EvalJs(shell(),
"document.featurePolicy.features().includes('"
@ -598,8 +176,7 @@ class PrivacySandboxAdsAPIsM1OverrideNoFeatureBrowserTest
IN_PROC_BROWSER_TEST_F(PrivacySandboxAdsAPIsM1OverrideNoFeatureBrowserTest,
OverrideWithoutFeature_IDLNotExposed) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_without_ads_apis_ot.html")));
EXPECT_TRUE(NavigateToURL(shell(), GURL("https://example.test/title1.html")));
EXPECT_EQ(false, EvalJs(shell(),
"document.featurePolicy.features().includes('"

@ -114,9 +114,9 @@ class SharedStorageWorkletDevToolsAgentHostTest
SharedStorageDocumentServiceImpl::GetOrCreateForCurrentDocument(
main_rfh);
document_service->CreateWorklet(
GURL("https://www.google.com/script.js"),
network::mojom::CredentialsMode::kSameOrigin,
{blink::mojom::OriginTrialFeature::kSharedStorageAPI},
network::mojom::CredentialsMode::kSameOrigin, {},
std::move(worklet_host), base::DoNothing());
SharedStorageWorkletHostManager* manager =

@ -20210,16 +20210,15 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_NE(signals, nullptr);
}
class AdsAPIsOriginTrialBrowserTest : public ContentBrowserTest {
class BiddingAndAuctionServerAPIsOriginTrialBrowserTest
: public ContentBrowserTest {
public:
AdsAPIsOriginTrialBrowserTest() {
// Disable `kFledgeBiddingAndAuctionServer` to show that it won't affect the
// exposure of the `adAuctionHeaders` fetch param.
BiddingAndAuctionServerAPIsOriginTrialBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPrivacySandboxAdsAPIs,
blink::features::kInterestGroupStorage},
/*disabled_features=*/{
blink::features::kFledgeBiddingAndAuctionServer});
/*enabled_features=*/{blink::features::kFledge,
blink::features::kInterestGroupStorage,
blink::features::kFledgeBiddingAndAuctionServer},
{});
}
void SetUpOnMainThread() override {
@ -20233,9 +20232,6 @@ class AdsAPIsOriginTrialBrowserTest : public ContentBrowserTest {
url_loader_interceptor_ =
std::make_unique<URLLoaderInterceptor>(base::BindLambdaForTesting(
[&](URLLoaderInterceptor::RequestParams* params) -> bool {
last_request_is_ad_auction_header_request_ =
params->url_request.ad_auction_headers;
URLLoaderInterceptor::WriteResponse(
base::StrCat(
{kBaseDataDir, params->url_request.url.path_piece()}),
@ -20255,87 +20251,12 @@ class AdsAPIsOriginTrialBrowserTest : public ContentBrowserTest {
.root();
}
bool last_request_is_ad_auction_header_request() const {
return last_request_is_ad_auction_header_request_;
}
private:
bool last_request_is_ad_auction_header_request_ = false;
std::unique_ptr<URLLoaderInterceptor> url_loader_interceptor_;
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(AdsAPIsOriginTrialBrowserTest,
AdsAPIsOriginTrial_AdAuctionHeadersAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace("fetch($1, {adAuctionHeaders: true})",
GURL("https://example.test/empty.html"))));
EXPECT_TRUE(last_request_is_ad_auction_header_request());
}
IN_PROC_BROWSER_TEST_F(
AdsAPIsOriginTrialBrowserTest,
AdsAPIsOriginTrial_NoFetchParam_AdAuctionHeadersNotAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace("fetch($1)",
GURL("https://example.test/empty.html"))));
EXPECT_FALSE(last_request_is_ad_auction_header_request());
}
class AdsAPIsOriginTrialWithMainFledgeFeatureDisabledBrowserTest
: public AdsAPIsOriginTrialBrowserTest {
public:
AdsAPIsOriginTrialWithMainFledgeFeatureDisabledBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPrivacySandboxAdsAPIs},
/*disabled_features=*/{blink::features::kInterestGroupStorage});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(
AdsAPIsOriginTrialWithMainFledgeFeatureDisabledBrowserTest,
AdsAPIsOriginTrial_AdAuctionHeadersNotAllowedForFetch) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_TRUE(
ExecJs(shell()->web_contents(),
content::JsReplace("fetch($1, {adAuctionHeaders: true})",
GURL("https://example.test/empty.html"))));
EXPECT_FALSE(last_request_is_ad_auction_header_request());
}
class BiddingAndAuctionServerAPIsOriginTrialBrowserTest
: public AdsAPIsOriginTrialBrowserTest {
public:
BiddingAndAuctionServerAPIsOriginTrialBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kFledge,
blink::features::kInterestGroupStorage,
blink::features::kFledgeBiddingAndAuctionServer},
{});
}
private:
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(BiddingAndAuctionServerAPIsOriginTrialBrowserTest,
RightOTFeatureEnabled) {
EXPECT_TRUE(NavigateToURL(
@ -20345,15 +20266,6 @@ IN_PROC_BROWSER_TEST_F(BiddingAndAuctionServerAPIsOriginTrialBrowserTest,
"'getInterestGroupAdAuctionData' in navigator"));
}
IN_PROC_BROWSER_TEST_F(BiddingAndAuctionServerAPIsOriginTrialBrowserTest,
WrongOTFeatureDisabled) {
EXPECT_TRUE(NavigateToURL(
shell(), GURL("https://example.test/page_with_ads_apis_ot.html")));
EXPECT_EQ(false, EvalJs(shell()->web_contents(),
"'getInterestGroupAdAuctionData' in navigator"));
}
class InterestGroupBiddingAndAuctionServerBrowserTest
: public InterestGroupBrowserTest {
public:

@ -58,7 +58,6 @@
#include "content/public/test/test_select_url_fenced_frame_config_observer.h"
#include "content/public/test/test_shared_storage_header_observer.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "content/test/fenced_frame_test_utils.h"
@ -13605,72 +13604,4 @@ IN_PROC_BROWSER_TEST_F(SharedStorageHeaderObserverBrowserTest,
EXPECT_TRUE(observer_->operations().empty());
}
class SharedStorageOriginTrialBrowserTest : public ContentBrowserTest {
public:
SharedStorageOriginTrialBrowserTest() {
feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPrivacySandboxAdsAPIs,
blink::features::kSharedStorageAPI},
/*disabled_features=*/{features::kPrivacySandboxAdsAPIsM1Override});
}
void SetUpOnMainThread() override {
ContentBrowserTest::SetUpOnMainThread();
// We use a URLLoaderInterceptor, rather than the EmbeddedTestServer, since
// the origin trial token in the response is associated with a fixed
// origin, whereas EmbeddedTestServer serves content on a random port.
url_loader_interceptor_ =
std::make_unique<URLLoaderInterceptor>(base::BindLambdaForTesting(
[](URLLoaderInterceptor::RequestParams* params) -> bool {
base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath test_data_dir;
CHECK(base::PathService::Get(DIR_TEST_DATA, &test_data_dir));
std::string relative_path =
params->url_request.url.path().substr(1);
base::FilePath file_path =
test_data_dir.AppendASCII(relative_path);
URLLoaderInterceptor::WriteResponse(file_path,
params->client.get());
return true;
}));
}
void TearDownOnMainThread() override {
// Resetting `URLLoaderInterceptor` needs a single-threaded context. Thus,
// reset it here instead of during destruction of `this`.
url_loader_interceptor_.reset();
}
private:
std::unique_ptr<URLLoaderInterceptor> url_loader_interceptor_;
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(SharedStorageOriginTrialBrowserTest,
OriginTrialEnabled_SharedStorageClassExposedInWorklet) {
EXPECT_TRUE(
NavigateToURL(shell(), GURL("https://example.test/attribution_reporting/"
"page_with_ads_apis_ot.html")));
EXPECT_TRUE(ExecJs(shell(), R"(
// Try accessing the `SharedStorage` interface which is gated by
// [RuntimeEnabled=SharedStorageAPI] which has an associated Origin Trial
// feature. If the OT features are correctly propagated to the worklet
// environment, the module script should execute successfully.
let module_content = `
SharedStorage;
`;
let blob = new Blob([module_content], {type: 'text/javascript'});
sharedStorage.worklet.addModule(URL.createObjectURL(blob));
)"));
}
} // namespace content

@ -5831,7 +5831,6 @@ data/attribution_reporting/interop/trigger_header_error_debug_report.json
data/attribution_reporting/interop/trigger_verbose_debug_report_source_debug_permission.json
data/attribution_reporting/interop/unsuitable_response_url.json
data/attribution_reporting/interop/verbose_debug_report_multiple_data.json
data/attribution_reporting/page_with_ads_apis_ot.html
data/attribution_reporting/page_with_conversion_measurement_disabled.html
data/attribution_reporting/page_with_conversion_measurement_disabled.html.mock-http-headers
data/attribution_reporting/page_with_conversion_redirect.html
@ -6903,7 +6902,6 @@ data/interest_group/multiply.wat
data/interest_group/page-with-fledge-permissions-policy-disabled-in-iframe.html
data/interest_group/page-with-fledge-permissions-policy-disabled.html
data/interest_group/page-with-fledge-permissions-policy-disabled.html.mock-http-headers
data/interest_group/page_with_ads_apis_ot.html
data/interest_group/page_with_ba_server_ot.html
data/interest_group/page_with_custom_ad_auction_result_header.html
data/interest_group/page_with_custom_ad_auction_result_header.html.mock-http-headers

@ -1,8 +0,0 @@
<html>
<head>
<!-- TODO(johnidel): Find a better way to provide this token, as this has an expiration in 2033.
Generate this token with the command:
generate_token.py https://example.test PrivacySandboxAdsAPIs --expire-timestamp=2000000000 -->
<meta http-equiv="origin-trial" content="A5tnx3M8YgPvr7n0sKItbVfImY3JFbP+KhW5eL3wxOHDTKpJ/AcBbmFpEx8Feve0uzgxVIfCPSjw++Gv1GCPkQUAAABgeyJvcmlnaW4iOiAiaHR0cHM6Ly9leGFtcGxlLnRlc3Q6NDQzIiwgImZlYXR1cmUiOiAiUHJpdmFjeVNhbmRib3hBZHNBUElzIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9">
</head>
</html>

@ -1,8 +0,0 @@
<html>
<head>
<!-- TODO(johnidel): Find a better way to provide this token, as this has an expiration in 2033.
Generate this token with the command:
generate_token.py https://example.test PrivacySandboxAdsAPIs --expire-timestamp=2000000000 -->
<meta http-equiv="origin-trial" content="A5tnx3M8YgPvr7n0sKItbVfImY3JFbP+KhW5eL3wxOHDTKpJ/AcBbmFpEx8Feve0uzgxVIfCPSjw++Gv1GCPkQUAAABgeyJvcmlnaW4iOiAiaHR0cHM6Ly9leGFtcGxlLnRlc3Q6NDQzIiwgImZlYXR1cmUiOiAiUHJpdmFjeVNhbmRib3hBZHNBUElzIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9">
</head>
</html>

@ -1910,10 +1910,6 @@ const base::FeatureParam<bool> kPrewarmFantasy = {&kPrewarmDefaultFontFamilies,
"prewarm_fantasy", false};
#endif
BASE_FEATURE(kPrivacySandboxAdsAPIs,
"PrivacySandboxAdsAPIs",
base::FEATURE_DISABLED_BY_DEFAULT);
// Enables the Private Aggregation API. Note that this API also requires the
// `kPrivacySandboxAggregationService` to be enabled to successfully send
// reports.

@ -1270,8 +1270,6 @@ BLINK_COMMON_EXPORT extern const base::FeatureParam<bool> kPrewarmCursive;
BLINK_COMMON_EXPORT extern const base::FeatureParam<bool> kPrewarmFantasy;
#endif
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kPrivacySandboxAdsAPIs);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kPrivateAggregationApi);
BLINK_COMMON_EXPORT extern const base::FeatureParam<bool>
kPrivateAggregationApiEnabledInSharedStorage;

@ -668,10 +668,7 @@ AttributionSrcLoader::ReportingOriginForUrlIfValid(
UseCounter::Count(window,
mojom::blink::WebFeature::kAttributionReportingAPIAll);
// Only record the ads APIs counter if enabled in that manner.
if (RuntimeEnabledFeatures::PrivacySandboxAdsAPIsEnabled(window)) {
UseCounter::Count(window, mojom::blink::WebFeature::kPrivacySandboxAdsAPIs);
}
UseCounter::Count(window, mojom::blink::WebFeature::kPrivacySandboxAdsAPIs);
// The Attribution-Reporting-Support header is set on the request in the
// network service and the context is unavailable. This is an approximate

@ -515,9 +515,6 @@ void OriginTrialContext::AddForceEnabledTrials(
}
bool OriginTrialContext::CanEnableTrialFromName(const StringView& trial_name) {
if (trial_name == "PrivacySandboxAdsAPIs")
return base::FeatureList::IsEnabled(features::kPrivacySandboxAdsAPIs);
if (trial_name == "FledgeBiddingAndAuctionServer") {
return base::FeatureList::IsEnabled(features::kInterestGroupStorage) &&
base::FeatureList::IsEnabled(
@ -571,42 +568,6 @@ bool OriginTrialContext::CanEnableTrialFromName(const StringView& trial_name) {
return true;
}
Vector<mojom::blink::OriginTrialFeature>
OriginTrialContext::RestrictedFeaturesForTrial(const String& trial_name) {
if (trial_name == "PrivacySandboxAdsAPIs") {
Vector<mojom::blink::OriginTrialFeature> restricted;
if (!base::FeatureList::IsEnabled(features::kInterestGroupStorage)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kFledge);
}
if (!base::FeatureList::IsEnabled(features::kBrowsingTopics)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kTopicsAPI);
}
if (!base::FeatureList::IsEnabled(features::kBrowsingTopics) ||
!base::FeatureList::IsEnabled(features::kBrowsingTopicsDocumentAPI)) {
restricted.push_back(
mojom::blink::OriginTrialFeature::kTopicsDocumentAPI);
}
if (!base::FeatureList::IsEnabled(
attribution_reporting::features::kConversionMeasurement)) {
restricted.push_back(
mojom::blink::OriginTrialFeature::kAttributionReporting);
}
if (!base::FeatureList::IsEnabled(features::kFencedFrames)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kFencedFrames);
}
if (!base::FeatureList::IsEnabled(features::kSharedStorageAPI)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kSharedStorageAPI);
}
if (!base::FeatureList::IsEnabled(features::kFencedFramesAPIChanges)) {
restricted.push_back(
mojom::blink::OriginTrialFeature::kFencedFramesAPIChanges);
}
return restricted;
}
return {};
}
OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
const String& trial_name,
base::Time expiry_time) {
@ -619,9 +580,6 @@ OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
return result;
}
Vector<mojom::blink::OriginTrialFeature> restricted =
RestrictedFeaturesForTrial(trial_name);
bool did_enable_feature = false;
for (mojom::blink::OriginTrialFeature feature :
origin_trials::FeaturesForTrial(trial_name.Utf8())) {
@ -631,13 +589,6 @@ OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
continue;
}
if (restricted.Contains(feature)) {
DVLOG(1) << "EnableTrialFromName: feature " << static_cast<int>(feature)
<< " is restricted from being enabled via the trial: "
<< trial_name << ".";
continue;
}
did_enable_feature = true;
enabled_features_.insert(feature);
origin_trial_features.push_back(feature);

@ -211,13 +211,6 @@ class CORE_EXPORT OriginTrialContext final
// invalid in the browser's present configuration).
bool CanEnableTrialFromName(const StringView& trial_name);
// Returns features which are currently restricted for a given trial name,
// these features *will not* be enabled by the origin trial infrastructure if
// the given trial is enabled. The corresponding runtime features may still be
// enabled via command line flags, etc.
Vector<mojom::blink::OriginTrialFeature> RestrictedFeaturesForTrial(
const String& trial_name);
// Enable features by trial name. Returns a OriginTrialFeaturesEnabled struct
// containing whether one or more trials were enabled, and a Vector of the
// OriginTrialFeatures representing those trials.

@ -2636,12 +2636,7 @@ void RecordCommonFledgeUseCounters(Document* document) {
return;
}
UseCounter::Count(document, mojom::blink::WebFeature::kFledge);
// Only record the ads APIs counter if enabled in that manner.
if (RuntimeEnabledFeatures::PrivacySandboxAdsAPIsEnabled(
document->GetExecutionContext())) {
UseCounter::Count(document,
mojom::blink::WebFeature::kPrivacySandboxAdsAPIs);
}
UseCounter::Count(document, mojom::blink::WebFeature::kPrivacySandboxAdsAPIs);
}
// Several dictionary members are being renamed -- to maintain compatibility

@ -96,11 +96,7 @@ BrowsingTopicsDocumentSupplement::GetBrowsingTopics(
return ScriptPromise<IDLSequence<BrowsingTopic>>();
}
if (RuntimeEnabledFeatures::PrivacySandboxAdsAPIsEnabled(
document.GetExecutionContext())) {
UseCounter::Count(document,
mojom::blink::WebFeature::kPrivacySandboxAdsAPIs);
}
UseCounter::Count(document, mojom::blink::WebFeature::kPrivacySandboxAdsAPIs);
auto* resolver =
MakeGarbageCollected<ScriptPromiseResolver<IDLSequence<BrowsingTopic>>>(

@ -610,7 +610,7 @@ class SharedStorageWorkletTest : public PageTestBase {
KURL(kModuleScriptSource),
/*starter_origin=*/
SecurityOrigin::Create(KURL(kModuleScriptSource)),
Vector({mojom::blink::OriginTrialFeature::kSharedStorageAPI}),
Vector<blink::mojom::OriginTrialFeature>(),
/*devtools_worker_token=*/base::UnguessableToken(),
std::move(pending_devtools_host_remote),
std::move(pending_code_cache_host_remote),

@ -358,9 +358,7 @@
},
{
name: "AttributionReporting",
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
status: "experimental",
status: "stable",
base_feature: "none",
public: true,
},
@ -1687,18 +1685,16 @@
// Portals, as we require the support of the browser process to fully
// enable the feature. Enabling this runtime enabled feature alone has no
// effect.
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
public: true,
status: "stable",
},
{
name: "FencedFramesAPIChanges",
// Various new IDL attributes on the <fencedframe> element (such as
// `config`, `sandbox`, and `allow`).
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
base_feature_status: "enabled",
copied_from_base_feature_if: "enabled_or_overridden",
status: "stable",
},
{
name: "FencedFramesDefaultMode",
@ -1812,8 +1808,6 @@
name: "Fledge",
status: "stable",
base_feature: "none",
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
public: true,
},
{
@ -3165,14 +3159,6 @@
name:"PrettyPrintJSONDocument",
status: "stable",
},
// The RTE feature encompasses multiple APIs, including: Attribution
// Reporting, FLEDGE, Topics and Fenced Frames.
{
name: "PrivacySandboxAdsAPIs",
base_feature: "none",
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
},
{
// Controls whether filtering IDs can be specified for Private Aggregation
// contributions. If disabled, any IDs will be ignored.
@ -3689,9 +3675,8 @@
{
name: "SharedStorageAPI",
base_feature: "none",
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
public: true,
status: "stable",
},
{
name: "SharedStorageAPIM118",
@ -4037,16 +4022,14 @@
{
name: "TopicsAPI",
base_feature: "none",
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
public: true,
status: "stable",
},
{
name: "TopicsDocumentAPI",
base_feature: "none",
origin_trial_feature_name: "PrivacySandboxAdsAPIs",
origin_trial_allows_third_party: true,
public: true,
status: "stable",
},
{
name: "TopLevelTpcd",