Skip to content

Commit

Permalink
Enable DoNotTrackTest.NotEnabled
Browse files Browse the repository at this point in the history
crrev.com/c/1382669 started to set BrowserClient on an older Android, and it caused
test failures. This CL is to skip setting custom BrowserClient for a KitKat or older Android.

Bug: 916978
Change-Id: Ia6a7a9be71ffdba9539a72eceff3883c710527af
Reviewed-on: https://chromium-review.googlesource.com/c/1390032
Reviewed-by: Kinuko Yasuda <[email protected]>
Commit-Queue: Makoto Shimazu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#618902}
  • Loading branch information
makotoshimazu authored and Commit Bot committed Dec 26, 2018
1 parent 35a93c1 commit 2112209
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions content/browser/do_not_track_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,29 @@ class MockContentBrowserClient final : public ContentBrowserClient {
class DoNotTrackTest : public ContentBrowserTest {
protected:
void SetUpOnMainThread() override {
#if defined(OS_ANDROID)
// TODO(crbug.com/864403): It seems that we call unsupported Android APIs on
// KitKat when we set a ContentBrowserClient. Don't call such APIs and make
// this test available on KitKat.
int32_t major_version = 0, minor_version = 0, bugfix_version = 0;
base::SysInfo::OperatingSystemVersionNumbers(&major_version, &minor_version,
&bugfix_version);
if (major_version < 5)
return;
#endif

original_client_ = SetBrowserClientForTesting(&client_);
}
void TearDownOnMainThread() override {
SetBrowserClientForTesting(original_client_);
if (original_client_)
SetBrowserClientForTesting(original_client_);
}

// Returns false if we cannot enable do not track. It happens only when
// Android Kitkat or older systems.
// TODO(crbug.com/864403): It seems that we call unsupported Android APIs on
// KitKat when we set a ContentBrowserClient. Don't call such APIs and make
// this test available on KitKat.
bool EnableDoNotTrack() {
#if defined(OS_ANDROID)
int32_t major_version = 0, minor_version = 0, bugfix_version = 0;
base::SysInfo::OperatingSystemVersionNumbers(&major_version, &minor_version,
&bugfix_version);
if (major_version < 5)
if (!original_client_)
return false;
#endif
client_.EnableDoNotTrack();
RendererPreferences* prefs =
shell()->web_contents()->GetMutableRendererPrefs();
Expand Down Expand Up @@ -117,13 +121,7 @@ CaptureHeaderHandlerAndReturnScript(
}

// Checks that the DNT header is not sent by default.
// Disabled on Android due to test failures: crbug.com/916978
#if defined(OS_ANDROID)
#define MAYBE_NotEnabled DISABLED_NotEnabled
#else
#define MAYBE_NotEnabled NotEnabled
#endif
IN_PROC_BROWSER_TEST_F(DoNotTrackTest, MAYBE_NotEnabled) {
IN_PROC_BROWSER_TEST_F(DoNotTrackTest, NotEnabled) {
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_TRUE(NavigateToURL(shell(), GetURL("/echoheader?DNT")));
ExpectPageTextEq("None");
Expand Down

0 comments on commit 2112209

Please sign in to comment.