| Index: components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
|
| diff --git a/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc b/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
|
| index 8f2bc729f06b474421eb06b26e3e7322e8ff4e3d..04785bb436b045a5ae37204c737981e5b1ceb509 100644
|
| --- a/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
|
| +++ b/components/browser_context_keyed_service/browser_context_keyed_service_factory.cc
|
| @@ -20,6 +20,12 @@ void BrowserContextKeyedServiceFactory::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 |BrowserContextShutdown| from causing
|
| + // |AssertBrowserContextWasntDestroyed| to raise an error.
|
| + dependency_manager_->MarkBrowserContextLiveForTesting(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.
|
|
|