Commit 91754814 authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Chromium LUCI CQ

Update Incognito history leakage tests.

This CL removes the parameterized test to detect history based leaks
from Incognito to regular and instead adds two single non-parameterized
tests to check a) History leak from Incognito tabbed Activity and
b) History leak from Incognito CustomTabActivity.

Since, for all different kind of profiles the history service (via which
one can query history) remains the same. It just suffices to check
that for "Incognito cases" we don't write an entry. If we don't write
an entry then one can't read it via the history service.

Bug: 1140751
Change-Id: Icb038bfd034f509fd2a806a5dea82065987b0f29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2621061Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842021}
parent 76be69b8
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.incognito;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
......@@ -26,7 +27,7 @@ import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Criteria;
import org.chromium.base.test.util.CriteriaHelper;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils;
import org.chromium.chrome.browser.customtabs.IncognitoCustomTabActivityTestRule;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
......@@ -120,46 +121,26 @@ public class IncognitoHistoryLeakageTest {
}
}
/**
* We test history leaks from Incognito Tab/CCT to Regular Tab/CCT and not the other way
* round because incognito session don't have a history service of their own and rely on the
* history service of their original regular profile. So, if we open a regular profile
* first and visit a url and test for the url visibility in the history service provided by
* incognito session it would always be visible as they both share the same history service.
*/
@Test
@LargeTest
@UseMethodParameter(TestParams.IncognitoToRegular.class)
@DisabledTest(message = "Flaky - https://crbug.com/1140751")
public void testBrowsingHistoryDoNotLeakFromIncognitoToRegular(
String incognitoActivityType, String regularActivityType) throws TimeoutException {
ActivityType incognitoActivity = ActivityType.valueOf(incognitoActivityType);
ActivityType regularActivity = ActivityType.valueOf(regularActivityType);
// We visit the mTestPage1 from incognito
Tab tab1 = incognitoActivity.launchUrl(
mChromeActivityTestRule, mCustomTabActivityTestRule, mTestPage1);
List<HistoryItem> historyEntriesOfIncognitoMode = getBrowsingHistory(tab1);
public void testBrowsingHistoryDoNotLeakFromIncognitoTabbedActivity() throws TimeoutException {
mChromeActivityTestRule.startMainActivityOnBlankPage();
mChromeActivityTestRule.loadUrlInNewTab(mTestPage1, /*incognito=*/true);
List<HistoryItem> historyEntriesOfIncognitoMode =
getBrowsingHistory(mChromeActivityTestRule.getActivity().getActivityTab());
assertTrue(historyEntriesOfIncognitoMode.isEmpty());
}
// History from regular should also be empty as well, as currently, incognito and regular
// both share the same history service.
assertTrue(getBrowsingHistory(null).isEmpty());
// We visit mTestPage2 from regular
Tab tab2 = regularActivity.launchUrl(
mChromeActivityTestRule, mCustomTabActivityTestRule, mTestPage2);
List<HistoryItem> regularBrowsingHistory = getBrowsingHistory(tab2);
assertEquals(1, regularBrowsingHistory.size());
assertEquals(mTestPage2, regularBrowsingHistory.get(0).getUrl());
// Since the history service is shared with incognito, getting browsing history for
// incognito should return that of regular.
List<HistoryItem> incognitoBrowsingHistory = getBrowsingHistory(tab1);
assertEquals(1, incognitoBrowsingHistory.size());
assertEquals(mTestPage2, incognitoBrowsingHistory.get(0).getUrl());
@Test
@LargeTest
public void testBrowsingHistoryDoNotLeakFromIncognitoCustomTabActivity()
throws TimeoutException {
Intent intent = CustomTabsTestUtils.createMinimalIncognitoCustomTabIntent(
InstrumentationRegistry.getContext(), mTestPage1);
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent);
List<HistoryItem> historyEntriesOfIncognitoMode =
getBrowsingHistory(mCustomTabActivityTestRule.getActivity().getActivityTab());
assertTrue(historyEntriesOfIncognitoMode.isEmpty());
}
@Test
......
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