• Nate Fischer's avatar
    AW: fix crash in AwBrowserContextTest · 0bbefb9f
    Nate Fischer authored
    No change to production logic.
    
    This fixes a crash in AwBrowserContextTest. The issue was the second
    test in the suite (regardless of what that test did) would crash as soon
    as the setup constructs a TestContentClientInitializer. This is because
    a posted task created a NetworkConnectionTracker, running after
    TestContentClientInitializer's destructor nulled it out. It's invalid to
    re-set a NetworkConnectionTracker without first clearing it, triggering
    a DCHECK.
    
    We avoid this by pumping through the UI thread looper during the test
    teardown, so we're sure the background task has executed prior to
    destroying TestContentClientInitializer.
    
    This also fixes a memory leak in the test setup/teardown (we need to
    clean up the AwBrowserProcess instance), although this was unrelated
    to the bug.
    
    Bug: 990547
    Test: run_android_webview_unittests --num_retries=0 --gtest_filter=AwBrowserContextTest.*
    Change-Id: I16d03a1cf6d813b7052b8205d2936864397fc21e
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849174
    Commit-Queue: Nate Fischer <ntfschr@chromium.org>
    Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#704282}
    0bbefb9f
aw_browser_context_unittest.cc 2.79 KB