Commit 4ecc1b7a authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

[COOP] reporting. Reenable the OriginTrial test.

This reenable the two tests:
CoopReportingOriginTrialBrowserTest.AccessReportingWithToken
CoopReportingOriginTrialBrowserTest.CoopStateWithToken

They aren't working on Android, because the OriginTrialPolicy is not set
on this platform for BrowserTest in the browser process.

See the comment in the code below.

Bug: 1119555
Change-Id: I66cd03c9b8e1de26e9e21469149620eca43d67d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388120Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808372}
parent 7198fbfe
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "components/network_session_configurator/common/network_switches.h" #include "components/network_session_configurator/common/network_switches.h"
#include "content/browser/renderer_host/navigation_request.h" #include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/renderer_host/render_frame_host_impl.h"
...@@ -2433,6 +2434,39 @@ class CoopReportingOriginTrialBrowserTest : public ContentBrowserTest { ...@@ -2433,6 +2434,39 @@ class CoopReportingOriginTrialBrowserTest : public ContentBrowserTest {
net::EmbeddedTestServer* https_server() { return &https_server_; } net::EmbeddedTestServer* https_server() { return &https_server_; }
// On every platforms, except on Android, ContainMain is called for
// browsertest. This calls SetOriginTrialPolicyGetter.
// On Android, a meager re-implementation of ContentMainRunnerImpl is made by
// BrowserTestBase. This doesn't call SetOriginTrialPolicyGetter.
//
// So on Android + BrowserTestBase + browser process, the OriginTrial policy
// isn't setup. This is tracked by https://crbug.com/1123953
//
// To fix this we could:
//
// 1) Fix https://crbug.com/1123953. Call SetOriginTrialPolicyGetter using
// GetContentClient()->GetOriginTrialPolicy() from BrowserTestBase. This
// doesn't work, because GetContentClient() is private to the
// implementation of content/, unreachable from the test.
//
// 2) Setup our own blink::OriginTrialPolicy here, based on
// embedder_support::OriginTrialPolicy. This doesn't work, because this
// violate the DEPS rules.
//
// 3) Copy-paste the implementation of embedder_support::OriginTrialPolicy
// here. This doesn't really worth the cost.
//
// Instead we abandon testing the OriginTrial on the Android platform :-(
//
// TODO(https://crbug.com/1123953). Remove this once fixed.
bool IsOriginTrialPolicySetup() {
#if defined(OS_ANDROID)
return false;
#else
return true;
#endif
}
private: private:
void SetUpOnMainThread() final { void SetUpOnMainThread() final {
ContentBrowserTest::TearDownOnMainThread(); ContentBrowserTest::TearDownOnMainThread();
...@@ -2488,9 +2522,12 @@ IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest, ...@@ -2488,9 +2522,12 @@ IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest,
network::mojom::CrossOriginOpenerPolicyValue::kUnsafeNone); network::mojom::CrossOriginOpenerPolicyValue::kUnsafeNone);
} }
// TODO(http://crbug.com/1119555): Flaky on android-bfcache-rel.
IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest, IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest,
DISABLED_CoopStateWithToken) { CoopStateWithToken) {
// TODO(https://crbug.com/1123953). Remove this once fixed.
if (!IsOriginTrialPolicySetup())
return;
URLLoaderInterceptor interceptor(base::BindLambdaForTesting( URLLoaderInterceptor interceptor(base::BindLambdaForTesting(
[&](URLLoaderInterceptor::RequestParams* params) { [&](URLLoaderInterceptor::RequestParams* params) {
if (params->url_request.url != OriginTrialURL()) if (params->url_request.url != OriginTrialURL())
...@@ -2557,9 +2594,11 @@ IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest, ...@@ -2557,9 +2594,11 @@ IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest,
EXPECT_EQ("[]", reports); EXPECT_EQ("[]", reports);
} }
// TODO(http://crbug.com/1119555): Flaky on multiple builders.
IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest, IN_PROC_BROWSER_TEST_F(CoopReportingOriginTrialBrowserTest,
DISABLED_AccessReportingWithToken) { AccessReportingWithToken) {
// TODO(https://crbug.com/1123953). Remove this once fixed.
if (!IsOriginTrialPolicySetup())
return;
URLLoaderInterceptor interceptor(base::BindLambdaForTesting( URLLoaderInterceptor interceptor(base::BindLambdaForTesting(
[&](URLLoaderInterceptor::RequestParams* params) { [&](URLLoaderInterceptor::RequestParams* params) {
if (params->url_request.url != OriginTrialURL()) if (params->url_request.url != OriginTrialURL())
......
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