|
9 | 9 | #include <string> |
10 | 10 | #include <vector> |
11 | 11 |
|
12 | | -#include "base/containers/contains.h" |
13 | 12 | #include "base/files/file_util.h" |
14 | 13 | #include "base/path_service.h" |
15 | 14 | #include "base/run_loop.h" |
16 | 15 | #include "base/strings/strcat.h" |
17 | 16 | #include "base/strings/string_number_conversions.h" |
18 | | -#include "base/strings/stringprintf.h" |
19 | | -#include "base/task/task_observer.h" |
20 | 17 | #include "base/test/bind.h" |
21 | 18 | #include "base/test/scoped_feature_list.h" |
22 | 19 | #include "base/time/time.h" |
|
30 | 27 | #include "brave/components/psst/common/pref_names.h" |
31 | 28 | #include "brave/components/psst/common/psst_metadata_schema.h" |
32 | 29 | #include "chrome/browser/browser_process.h" |
33 | | -#include "chrome/browser/infobars/test_support/infobar_observer.h" |
34 | 30 | #include "chrome/browser/profiles/profile.h" |
35 | 31 | #include "chrome/browser/ui/browser_list.h" |
36 | 32 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
|
40 | 36 | #include "components/infobars/content/content_infobar_manager.h" |
41 | 37 | #include "components/infobars/core/confirm_infobar_delegate.h" |
42 | 38 | #include "components/infobars/core/infobar.h" |
43 | | -#include "components/web_modal/web_contents_modal_dialog_host.h" |
44 | 39 | #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 40 | +#include "content/public/browser/visibility.h" |
45 | 41 | #include "content/public/browser/web_contents.h" |
46 | 42 | #include "content/public/browser/web_ui.h" |
47 | 43 | #include "content/public/test/browser_test.h" |
@@ -398,14 +394,14 @@ class DialogCloseObserver : public content::WebContentsObserver { |
398 | 394 | explicit DialogCloseObserver(content::WebContents* web_contents) |
399 | 395 | : content::WebContentsObserver(web_contents) {} |
400 | 396 |
|
401 | | - void WebContentsDestroyed() override { run_loop_.Quit(); } |
402 | | - |
403 | | - void Wait() { |
404 | | - if (web_contents()) { |
405 | | - run_loop_.Run(); |
| 397 | + void OnVisibilityChanged(content::Visibility visibility) override { |
| 398 | + if (visibility == content::Visibility::HIDDEN) { |
| 399 | + run_loop_.Quit(); |
406 | 400 | } |
407 | 401 | } |
408 | 402 |
|
| 403 | + void Wait() { run_loop_.Run(); } |
| 404 | + |
409 | 405 | private: |
410 | 406 | base::RunLoop run_loop_; |
411 | 407 | }; |
@@ -483,7 +479,6 @@ class PsstTabWebContentsObserverBrowserTest : public PlatformBrowserTest { |
483 | 479 | // Ensure all pending tasks are completed before teardown |
484 | 480 | psst_settings_service_ = nullptr; |
485 | 481 | profile_ = nullptr; |
486 | | - base::RunLoop().RunUntilIdle(); |
487 | 482 | PlatformBrowserTest::TearDownOnMainThread(); |
488 | 483 | } |
489 | 484 |
|
@@ -624,9 +619,7 @@ IN_PROC_BROWSER_TEST_F(PsstTabWebContentsObserverBrowserTest, |
624 | 619 | EXPECT_EQ(confirm_delegate->GetIdentifier(), |
625 | 620 | infobars::InfoBarDelegate::BRAVE_PSST_INFOBAR_DELEGATE); |
626 | 621 |
|
627 | | - base::RunLoop().RunUntilIdle(); |
628 | 622 | confirm_delegate->Accept(); |
629 | | - base::RunLoop().RunUntilIdle(); |
630 | 623 |
|
631 | 624 | auto* wc = WaitForAndGetDialogWebContents(); |
632 | 625 | ASSERT_TRUE(wc); |
@@ -687,9 +680,7 @@ IN_PROC_BROWSER_TEST_F(PsstTabWebContentsObserverBrowserTest, |
687 | 680 | EXPECT_EQ(confirm_delegate->GetIdentifier(), |
688 | 681 | infobars::InfoBarDelegate::BRAVE_PSST_INFOBAR_DELEGATE); |
689 | 682 |
|
690 | | - base::RunLoop().RunUntilIdle(); |
691 | 683 | confirm_delegate->Accept(); |
692 | | - base::RunLoop().RunUntilIdle(); |
693 | 684 |
|
694 | 685 | auto* dialog_wc = WaitForAndGetDialogWebContents(); |
695 | 686 | ASSERT_TRUE(dialog_wc); |
|
0 commit comments