| Index: content/shell/renderer/test_runner/test_runner.cc
|
| diff --git a/content/shell/renderer/test_runner/test_runner.cc b/content/shell/renderer/test_runner/test_runner.cc
|
| index 869cc81368207e5c1e7623a8486ac436b8184bc0..a599a6016a93f56235e47a028f64b5bcb8381909 100644
|
| --- a/content/shell/renderer/test_runner/test_runner.cc
|
| +++ b/content/shell/renderer/test_runner/test_runner.cc
|
| @@ -7,6 +7,7 @@
|
| #include <limits>
|
|
|
| #include "base/logging.h"
|
| +#include "base/run_loop.h"
|
| #include "content/public/test/layouttest_support.h"
|
| #include "content/shell/common/test_runner/test_preferences.h"
|
| #include "content/shell/renderer/binding_helpers.h"
|
| @@ -305,6 +306,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
|
| int WebHistoryItemCount();
|
| bool InterceptPostMessage();
|
| void SetInterceptPostMessage(bool value);
|
| + void Sleep(int milliseconds);
|
|
|
| void NotImplemented(const gin::Arguments& args);
|
|
|
| @@ -460,6 +462,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
|
| &TestRunnerBindings::DumpResourceRequestCallbacks)
|
| .SetMethod("dumpResourceResponseMIMETypes",
|
| &TestRunnerBindings::DumpResourceResponseMIMETypes)
|
| + .SetMethod("sleep", &TestRunnerBindings::Sleep)
|
| .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed)
|
| .SetMethod("setMediaAllowed", &TestRunnerBindings::SetMediaAllowed)
|
| .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed)
|
| @@ -1116,6 +1119,11 @@ void TestRunnerBindings::DumpResourceResponseMIMETypes() {
|
| runner_->DumpResourceResponseMIMETypes();
|
| }
|
|
|
| +void TestRunnerBindings::Sleep(int milliseconds) {
|
| + if (runner_)
|
| + runner_->Sleep(milliseconds);
|
| +}
|
| +
|
| void TestRunnerBindings::SetImagesAllowed(bool allowed) {
|
| if (runner_)
|
| runner_->SetImagesAllowed(allowed);
|
| @@ -2617,6 +2625,19 @@ void TestRunner::DumpResourceResponseMIMETypes() {
|
| dump_resource_reqponse_mime_types_ = true;
|
| }
|
|
|
| +void TestRunner::Sleep(int milliseconds) {
|
| + web_view_->setDefersLoading(true);
|
| +
|
| + base::MessageLoop* ml = base::MessageLoop::current();
|
| + base::MessageLoop::ScopedNestableTaskAllower allow_nested_tasks(ml);
|
| + base::RunLoop run_loop;
|
| + ml->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(),
|
| + base::TimeDelta::FromMilliseconds(milliseconds));
|
| + run_loop.Run();
|
| +
|
| + web_view_->setDefersLoading(false);
|
| +}
|
| +
|
| void TestRunner::SetImagesAllowed(bool allowed) {
|
| web_permissions_->SetImagesAllowed(allowed);
|
| }
|
|
|