diff options
Diffstat (limited to 'chromium/chrome/browser/ui/webui/web_ui_test_handler.cc')
-rw-r--r-- | chromium/chrome/browser/ui/webui/web_ui_test_handler.cc | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc index 8ae8cd38394..efe8811db00 100644 --- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc +++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc @@ -21,7 +21,7 @@ #include "content/public/browser/web_ui.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/common/associated_interfaces/associated_interface_provider.h" +#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" using content::RenderViewHost; @@ -29,10 +29,11 @@ WebUITestHandler::WebUITestHandler() : test_done_(false), test_succeeded_(false), run_test_done_(false), - run_test_succeeded_(false), - is_waiting_(false) { + run_test_succeeded_(false) { } +WebUITestHandler::~WebUITestHandler() = default; + void WebUITestHandler::PreloadJavaScript(const base::string16& js_text, RenderViewHost* preload_host) { DCHECK(preload_host); @@ -59,15 +60,14 @@ bool WebUITestHandler::RunJavaScriptTestWithResult( } void WebUITestHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback("testResult", - base::Bind(&WebUITestHandler::HandleTestResult, base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "testResult", base::BindRepeating(&WebUITestHandler::HandleTestResult, + base::Unretained(this))); } void WebUITestHandler::HandleTestResult(const base::ListValue* test_result) { - // Quit the message loop if |is_waiting_| so waiting process can get result or - // error. To ensure this gets done, do this before ASSERT* calls. - if (is_waiting_) - base::RunLoop::QuitCurrentWhenIdleDeprecated(); + // To ensure this gets done, do this before ASSERT* calls. + quit_closure_.Run(); SCOPED_TRACE("WebUITestHandler::HandleTestResult"); @@ -84,10 +84,8 @@ void WebUITestHandler::HandleTestResult(const base::ListValue* test_result) { } void WebUITestHandler::JavaScriptComplete(const base::Value* result) { - // Quit the message loop if |is_waiting_| so waiting process can get result or - // error. To ensure this gets done, do this before ASSERT* calls. - if (is_waiting_) - base::RunLoop::QuitCurrentWhenIdleDeprecated(); + // To ensure this gets done, do this before ASSERT* calls. + quit_closure_.Run(); SCOPED_TRACE("WebUITestHandler::JavaScriptComplete"); @@ -102,21 +100,24 @@ bool WebUITestHandler::WaitForResult() { SCOPED_TRACE("WebUITestHandler::WaitForResult"); test_done_ = false; run_test_done_ = false; - is_waiting_ = true; // Either sync test completion or the testDone() will cause message loop // to quit. - content::RunMessageLoop(); + { + base::RunLoop run_loop; + quit_closure_ = run_loop.QuitWhenIdleClosure(); + content::RunThisRunLoop(&run_loop); + } // Run a second message loop when not |run_test_done_| so that the sync test // completes, or |run_test_succeeded_| but not |test_done_| so async tests // complete. if (!run_test_done_ || (run_test_succeeded_ && !test_done_)) { - content::RunMessageLoop(); + base::RunLoop run_loop; + quit_closure_ = run_loop.QuitWhenIdleClosure(); + content::RunThisRunLoop(&run_loop); } - is_waiting_ = false; - // To succeed the test must execute as well as pass the test. return run_test_succeeded_ && test_succeeded_; } |