Commit 3c578027 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

[sync] Add test coverage for session tabs without header

This scenario verifies that, if a user ends up with corrupt data
consisting of tabs without their corresponding header entity,
nevertheless those tabs will eventually be subject to garbage
collection.

Change-Id: I50cec71a46e02731580b2c1ddb2a448533a0757c
Bug: None
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431024
Auto-Submit: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarVictor Vianna <victorvianna@google.com>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810563}
parent 98317b52
......@@ -710,6 +710,54 @@ IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest,
/*LOCAL_DELETION=*/0));
}
IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest,
GarbageCollectionOfForeignOrphanTabWithoutHeader) {
const std::string kForeignSessionTag = "ForeignSessionTag";
const SessionID kWindowId = SessionID::FromSerializedValue(5);
const SessionID kTabId1 = SessionID::FromSerializedValue(1);
const SessionID kTabId2 = SessionID::FromSerializedValue(2);
const base::Time kLastModifiedTime =
base::Time::Now() - base::TimeDelta::FromDays(100);
SessionSyncTestHelper helper;
// There are two orphan tab entities without a header entity.
sync_pb::EntitySpecifics tab1;
*tab1.mutable_session() =
helper.BuildTabSpecifics(kForeignSessionTag, kWindowId, kTabId1);
sync_pb::EntitySpecifics tab2;
*tab2.mutable_session() =
helper.BuildTabSpecifics(kForeignSessionTag, kWindowId, kTabId2);
for (const sync_pb::EntitySpecifics& specifics : {tab1, tab2}) {
GetFakeServer()->InjectEntity(
syncer::PersistentUniqueClientEntity::CreateFromSpecificsForTesting(
/*non_unique_name=*/"",
sync_sessions::SessionStore::GetClientTag(specifics.session()),
specifics,
/*creation_time=*/syncer::TimeToProtoTime(kLastModifiedTime),
/*last_modified_time=*/syncer::TimeToProtoTime(kLastModifiedTime)));
}
base::HistogramTester histogram_tester;
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
// Verify that all entities have been deleted.
WaitForHierarchyOnServer(SessionsHierarchy());
std::vector<sync_pb::SyncEntity> entities =
fake_server_->GetSyncEntitiesByModelType(syncer::SESSIONS);
for (const sync_pb::SyncEntity& entity : entities) {
EXPECT_NE(kForeignSessionTag, entity.specifics().session().session_tag());
}
EXPECT_EQ(
2, histogram_tester.GetBucketCount("Sync.ModelTypeEntityChange3.SESSION",
/*LOCAL_DELETION=*/0));
}
// Regression test for crbug.com/915133 that verifies the browser doesn't crash
// if the server sends corrupt data during initial merge.
IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, CorruptInitialForeignTab) {
......
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