Commit 59fb318b authored by Yao Xiao's avatar Yao Xiao Committed by Commit Bot

Add InterestCohortAPI origin trial config

Also removes the base::Feature kInterestCohortAPI, as there's no plan
for finch.


Bug: 1062736
Change-Id: I19d847b92ed57ae88a4fc99bc56039c7f4feaa9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434091
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812358}
parent e92e2156
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "components/sync/driver/test_sync_service.h" #include "components/sync/driver/test_sync_service.h"
#include "components/sync_user_events/fake_user_event_service.h" #include "components/sync_user_events/fake_user_event_service.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_request.h"
...@@ -119,11 +120,15 @@ class FlocIdProviderWithCustomizedServicesBrowserTest ...@@ -119,11 +120,15 @@ class FlocIdProviderWithCustomizedServicesBrowserTest
FlocIdProviderWithCustomizedServicesBrowserTest() { FlocIdProviderWithCustomizedServicesBrowserTest() {
scoped_feature_list_.InitWithFeatures( scoped_feature_list_.InitWithFeatures(
{features::kFlocIdComputedEventLogging, {features::kFlocIdComputedEventLogging,
features::kFlocIdBlocklistFiltering, features::kFlocIdBlocklistFiltering},
blink::features::kInterestCohortAPI},
{}); {});
} }
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"InterestCohortAPI");
}
// BrowserTestBase::SetUpInProcessBrowserTestFixture // BrowserTestBase::SetUpInProcessBrowserTestFixture
void SetUpInProcessBrowserTestFixture() override { void SetUpInProcessBrowserTestFixture() override {
subscription_ = subscription_ =
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/strings/strcat.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/embedder_support/switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/url_loader_interceptor.h"
#include "third_party/blink/public/common/features.h"
namespace federated_learning {
constexpr char kOriginTrialTestPublicKey[] =
"dRCs+TocuKkocNKa0AtZ4awrt9XKH2SQCI6o4FY6BNA=";
constexpr char kBaseDataDir[] = "chrome/test/data/federated_learning";
class FlocOriginTrialBrowserTest : public InProcessBrowserTest {
public:
FlocOriginTrialBrowserTest() = default;
void SetUpOnMainThread() override {
InProcessBrowserTest::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<content::URLLoaderInterceptor>(
base::BindLambdaForTesting(
[&](content::URLLoaderInterceptor::RequestParams* params) -> bool {
if (params->url_request.url.path_piece() !=
"/interest_cohort_api_origin_trial.html") {
return false;
}
content::URLLoaderInterceptor::WriteResponse(
base::StrCat(
{kBaseDataDir, params->url_request.url.path_piece()}),
params->client.get());
return true;
}));
}
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitchASCII(embedder_support::kOriginTrialPublicKey,
kOriginTrialTestPublicKey);
}
void TearDownOnMainThread() override { url_loader_interceptor_.reset(); }
bool HasInterestCohortApi(const content::ToRenderFrameHost& adapter) {
return EvalJs(adapter, R"(
document.interestCohort instanceof Function
)")
.ExtractBool();
}
GURL OriginTrialEnabledURL() const {
return GURL("https://example.test/interest_cohort_api_origin_trial.html");
}
GURL OriginTrialDisabledURL() const {
return GURL("https://disabled.test/interest_cohort_api_origin_trial.html");
}
content::WebContents* web_contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
private:
std::unique_ptr<content::URLLoaderInterceptor> url_loader_interceptor_;
};
IN_PROC_BROWSER_TEST_F(FlocOriginTrialBrowserTest, OriginTrialEnabled) {
ui_test_utils::NavigateToURL(browser(), OriginTrialEnabledURL());
EXPECT_TRUE(HasInterestCohortApi(web_contents()));
}
IN_PROC_BROWSER_TEST_F(FlocOriginTrialBrowserTest, OriginTrialDisabled) {
ui_test_utils::NavigateToURL(browser(), OriginTrialDisabledURL());
EXPECT_FALSE(HasInterestCohortApi(web_contents()));
}
} // namespace federated_learning
...@@ -1011,6 +1011,7 @@ if (!is_android) { ...@@ -1011,6 +1011,7 @@ if (!is_android) {
"../browser/fast_shutdown_browsertest.cc", "../browser/fast_shutdown_browsertest.cc",
"../browser/favicon/content_favicon_driver_browsertest.cc", "../browser/favicon/content_favicon_driver_browsertest.cc",
"../browser/federated_learning/floc_id_provider_browsertest.cc", "../browser/federated_learning/floc_id_provider_browsertest.cc",
"../browser/federated_learning/floc_origin_trial_browsertest.cc",
"../browser/first_run/first_run_browsertest.cc", "../browser/first_run/first_run_browsertest.cc",
"../browser/geolocation/geolocation_browsertest.cc", "../browser/geolocation/geolocation_browsertest.cc",
"../browser/guest_view/mime_handler_view/chrome_mime_handler_view_browsertest.cc", "../browser/guest_view/mime_handler_view/chrome_mime_handler_view_browsertest.cc",
......
<html>
<!-- Generate this token with the command:
generate_token.py https://example.test InterestCohortAPI --expire-timestamp=2000000000 -->
<meta http-equiv="origin-trial" content="A9oBaKunexGq3fPd6P0cPXicqbLxccMCXZcXlVICMaBk61Jl0yBoCSxfwDdbDFh0n+XevlYAvTMEt2IYV+na2QUAAABceyJvcmlnaW4iOiAiaHR0cHM6Ly9leGFtcGxlLnRlc3Q6NDQzIiwgImZlYXR1cmUiOiAiSW50ZXJlc3RDb2hvcnRBUEkiLCAiZXhwaXJ5IjogMjAwMDAwMDAwMH0=" />
<iframe id="test"></iframe>
</html>
...@@ -352,7 +352,6 @@ void SetRuntimeFeaturesFromChromiumFeatures() { ...@@ -352,7 +352,6 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
{"HTMLImports", blink::features::kWebComponentsV0}, {"HTMLImports", blink::features::kWebComponentsV0},
{"IgnoreCrossOriginWindowWhenNamedAccessOnWindow", {"IgnoreCrossOriginWindowWhenNamedAccessOnWindow",
blink::features::kIgnoreCrossOriginWindowWhenNamedAccessOnWindow}, blink::features::kIgnoreCrossOriginWindowWhenNamedAccessOnWindow},
{"InterestCohortAPI", blink::features::kInterestCohortAPI},
{"LangClientHintHeader", features::kLangClientHintHeader}, {"LangClientHintHeader", features::kLangClientHintHeader},
{"LayoutNG", blink::features::kLayoutNG}, {"LayoutNG", blink::features::kLayoutNG},
{"LayoutNGFieldset", blink::features::kLayoutNGFieldset}, {"LayoutNGFieldset", blink::features::kLayoutNGFieldset},
......
...@@ -284,10 +284,6 @@ const base::Feature kStopNonTimersInBackground{ ...@@ -284,10 +284,6 @@ const base::Feature kStopNonTimersInBackground{
const base::Feature kStorageAccessAPI{"StorageAccessAPI", const base::Feature kStorageAccessAPI{"StorageAccessAPI",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Enable the Interest Cohort API. https://crbug.com/1062736.
const base::Feature kInterestCohortAPI{"InterestCohortAPI",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enable text snippets in URL fragments. https://crbug.com/919204. // Enable text snippets in URL fragments. https://crbug.com/919204.
const base::Feature kTextFragmentAnchor{"TextFragmentAnchor", const base::Feature kTextFragmentAnchor{"TextFragmentAnchor",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -77,7 +77,6 @@ BLINK_COMMON_EXPORT extern const base::Feature ...@@ -77,7 +77,6 @@ BLINK_COMMON_EXPORT extern const base::Feature
kFreezeBackgroundTabOnNetworkIdle; kFreezeBackgroundTabOnNetworkIdle;
BLINK_COMMON_EXPORT extern const base::Feature kStopNonTimersInBackground; BLINK_COMMON_EXPORT extern const base::Feature kStopNonTimersInBackground;
BLINK_COMMON_EXPORT extern const base::Feature kStorageAccessAPI; BLINK_COMMON_EXPORT extern const base::Feature kStorageAccessAPI;
BLINK_COMMON_EXPORT extern const base::Feature kInterestCohortAPI;
BLINK_COMMON_EXPORT extern const base::Feature kTextFragmentAnchor; BLINK_COMMON_EXPORT extern const base::Feature kTextFragmentAnchor;
BLINK_COMMON_EXPORT extern const base::Feature kFontAccess; BLINK_COMMON_EXPORT extern const base::Feature kFontAccess;
BLINK_COMMON_EXPORT extern const base::Feature kFileHandlingAPI; BLINK_COMMON_EXPORT extern const base::Feature kFileHandlingAPI;
......
...@@ -953,8 +953,8 @@ ...@@ -953,8 +953,8 @@
status: "stable", status: "stable",
}, },
{ {
// Enabled when blink::features::kInterestCohortAPI is enabled.
name: "InterestCohortAPI", name: "InterestCohortAPI",
origin_trial_feature_name: "InterestCohortAPI",
}, },
{ {
name: "IntersectionObserverDocumentScrollingElementRoot", name: "IntersectionObserverDocumentScrollingElementRoot",
......
<!DOCTYPE html>
<meta charset="utf-8">
<!-- Generate token with the command:
generate_token.py http://127.0.0.1:8000 InterestCohortAPI --expire-timestamp=2000000000 --version 3
-->
<meta http-equiv="origin-trial" content="A1q7Ss8yaDaFBy5/0JLZCpLDbCD0o4uPIJkE9YEkUUuOBdvmdJiBcoNSy9OvLuRh+XsWnW3zP+0UcWI2T1vP1AwAAABZeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiSW50ZXJlc3RDb2hvcnRBUEkiLCAiZXhwaXJ5IjogMjAwMDAwMDAwMH0=" />
<title>Interest Cohort API - interfaces exposed by origin trial</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/origin-trials-helper.js"></script>
<script>
'use strict'
test(t => {
assert_true(document.interestCohort instanceof Function, 'interestCohort function can be accessed on document');
}, 'Interest Cohort API entry point in Origin-Trial enabled document.');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment