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

Unified Diff: components/test_runner/test_runner.cc

Issue 1832673002: Add testRunner.runIdleTasks() to force idle tasks to run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: add test Created 4 years, 8 months 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
Index: components/test_runner/test_runner.cc
diff --git a/components/test_runner/test_runner.cc b/components/test_runner/test_runner.cc
index 9d306b16c3a34fdfe5c823a9da614320322c7857..c4c2a2d82533de5b14bc19e03b8a968043d9a8bc 100644
--- a/components/test_runner/test_runner.cc
+++ b/components/test_runner/test_runner.cc
@@ -248,6 +248,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void ResetTestHelperControllers();
void ResolveBeforeInstallPromptPromise(int request_id,
const std::string& platform);
+ void RunIdleTasks(v8::Local<v8::Function> callback);
void SendBluetoothManualChooserEvent(const std::string& event,
const std::string& argument);
void SetAcceptLanguages(const std::string& accept_languages);
@@ -554,6 +555,8 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
&TestRunnerBindings::ResetTestHelperControllers)
.SetMethod("resolveBeforeInstallPromptPromise",
&TestRunnerBindings::ResolveBeforeInstallPromptPromise)
+ .SetMethod("runIdleTasks",
+ &TestRunnerBindings::RunIdleTasks)
.SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup)
// The Bluetooth functions are specified at
@@ -1562,6 +1565,12 @@ void TestRunnerBindings::ResolveBeforeInstallPromptPromise(
runner_->ResolveBeforeInstallPromptPromise(request_id, platform);
}
+void TestRunnerBindings::RunIdleTasks(v8::Local<v8::Function> callback) {
+ if (!runner_)
+ return;
+ runner_->RunIdleTasks(callback);
+}
+
std::string TestRunnerBindings::PlatformName() {
if (runner_)
return runner_->platform_name_;
@@ -3021,6 +3030,14 @@ void TestRunner::ResolveBeforeInstallPromptPromise(
test_interfaces_->GetAppBannerClient()->ResolvePromise(request_id, platform);
}
+void TestRunner::RunIdleTasks(v8::Local<v8::Function> callback) {
+ scoped_ptr<InvokeCallbackTask> task(new InvokeCallbackTask(this, callback));
+ delegate_->RunIdleTasks(
+ base::Bind(&TestRunner::InvokeCallback,
+ weak_factory_.GetWeakPtr(),
+ base::Passed(&task)));
+}
+
void TestRunner::SetPOSIXLocale(const std::string& locale) {
delegate_->SetLocale(locale);
}

Powered by Google App Engine
This is Rietveld 408576698