Commit b90bef2d authored by Scott Violet's avatar Scott Violet Committed by Chromium LUCI CQ

cct: don't add extra header when incognito

This removes the cct extra header when in incognito mode.

BUG=1158518
TEST=doesNotSetHeaderWhenIncognito

Change-Id: I43724d127aa6971b686b89293ec8efea146dffdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2590705Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836806}
parent 716f3f80
......@@ -405,7 +405,9 @@ public class CustomTabActivityTabController implements InflationObserver {
mConnection.getClientPackageNameForSession(mSession)));
// clang-format on
mConnection.setClientDataHeaderForNewTab(mSession, webContents);
if (!tab.isIncognito()) {
mConnection.setClientDataHeaderForNewTab(mSession, webContents);
}
initializeTab(tab);
......
......@@ -113,6 +113,8 @@ public class CustomTabActivityContentTestEnvironment extends TestWatcher {
public Tab tabFromFactory;
public boolean isIncognito;
@Override
protected void starting(Description description) {
MockitoAnnotations.initMocks(this);
......@@ -242,6 +244,7 @@ public class CustomTabActivityContentTestEnvironment extends TestWatcher {
when(tab.getWebContents()).thenReturn(webContents);
NavigationController navigationController = mock(NavigationController.class);
when(webContents.getNavigationController()).thenReturn(navigationController);
when(tab.isIncognito()).thenAnswer((mock) -> isIncognito);
return tab;
}
}
......@@ -7,11 +7,14 @@ package org.chromium.chrome.browser.customtabs.content;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
......@@ -183,4 +186,20 @@ public class CustomTabActivityTabControllerUnitTest {
mTabController.detachAndStartReparenting(new Intent(), new Bundle(), mock(Runnable.class));
assertNull(env.tabProvider.getTab());
}
// Some websites replace the tab with a new one.
@Test
public void doesNotSetHeaderWhenIncognito() {
doAnswer((mock) -> {
fail("setClientDataHeaderForNewTab() should not be called for incognito tabs");
return null;
})
.when(env.connection)
.setClientDataHeaderForNewTab(any(), any());
env.isIncognito = true;
mTabController.onPreInflationStartup();
mTabController.finishNativeInitialization();
Tab tab = env.prepareTab();
assertTrue(tab.isIncognito());
}
}
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