Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1706)

Unified Diff: content/shell/renderer/test_runner/test_runner.cc

Issue 725593006: Implementation of TestRunner::Sleep (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: long line Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698