| Index: components/keyed_service/core/refcounted_keyed_service_factory.cc
|
| diff --git a/components/keyed_service/core/refcounted_keyed_service_factory.cc b/components/keyed_service/core/refcounted_keyed_service_factory.cc
|
| index 7c44c2ce3893fcf79297864fe0041e5914712900..7afecda34f6676c1c5aa3d3dac84ad66effad3b7 100644
|
| --- a/components/keyed_service/core/refcounted_keyed_service_factory.cc
|
| +++ b/components/keyed_service/core/refcounted_keyed_service_factory.cc
|
| @@ -28,6 +28,12 @@ void RefcountedKeyedServiceFactory::SetTestingFactory(
|
| // destruction.
|
| bool add_context = ArePreferencesSetOn(context);
|
|
|
| + // Ensure that |context| is not marked as stale (e.g., due to it aliasing an
|
| + // instance that was destroyed in an earlier test) in order to avoid accesses
|
| + // to |context| in |ContextShutdown| from causing
|
| + // |AssertBrowserContextWasntDestroyed| to raise an error.
|
| + MarkContextLive(context);
|
| +
|
| // We have to go through the shutdown and destroy mechanisms because there
|
| // are unit tests that create a service on a context and then change the
|
| // testing service mid-test.
|
|
|