Do not flush TaskScheduler in ~TestBrowserThreadBundle if it's not managed by it.

This fixes hangs in

New regression test hangs without matching 

We support adding a TestBrowserThreadBundle on top of an explicit
ScopedTaskEnvironment (i.e. to add named threads in unit tests that
already otherwise inherit a ScopedTaskEnvironment or need to provide a
custom one). However if the ScopedTaskEnvironment uses a QUEUED mode,
trying to flush it in ~TestBrowserThreadBundle() results in a hang.
Flushing TaskScheduler when it's not managed by that
TestBrowserThreadBundle was wrong anyways.

Bug: 708584, 689520
Change-Id: I3087537ad4f1065fc974170b00c25a676ff5e4c9
Reviewed-by: Avi Drissman <>
Commit-Queue: Gabriel Charette <>
Cr-Commit-Position: refs/heads/master@{#487481}
2 files changed