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

Unified Diff: extensions/renderer/api_test_base.cc

Issue 2556153002: [Extensions] Convert more callers of CallModuleMethod (Closed)
Patch Set: revert doc change Created 4 years 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 | « no previous file | extensions/renderer/module_system.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_test_base.cc
diff --git a/extensions/renderer/api_test_base.cc b/extensions/renderer/api_test_base.cc
index bbffee98c7dea4bf43489e5f6f336e61308af0aa..8a2babad979145f53a082275ac83f51dbe4df434 100644
--- a/extensions/renderer/api_test_base.cc
+++ b/extensions/renderer/api_test_base.cc
@@ -204,12 +204,21 @@ void ApiTestEnvironment::RunTestInner(const std::string& test_name,
const base::Closure& quit_closure) {
v8::HandleScope scope(env()->isolate());
ModuleSystem::NativesEnabledScope natives_enabled(env()->module_system());
- v8::Local<v8::Value> result =
- env()->module_system()->CallModuleMethod("testBody", test_name);
- if (!result->IsTrue()) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
- FAIL() << "Failed to run test \"" << test_name << "\"";
- }
+ v8::Local<v8::Value> result;
+ bool did_run = false;
+ auto callback = [](bool* did_run, const base::Closure& quit_closure,
+ const std::string& test_name,
+ const std::vector<v8::Local<v8::Value>>& result) {
+ *did_run = true;
+ if (result.empty() || result[0].IsEmpty() || !result[0]->IsTrue()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
+ FAIL() << "Failed to run test \"" << test_name << "\"";
+ }
+ };
+ env()->module_system()->CallModuleMethodSafe(
+ "testBody", test_name, 0, nullptr,
+ base::Bind(callback, &did_run, quit_closure, test_name));
+ ASSERT_TRUE(did_run);
}
void ApiTestEnvironment::RunPromisesAgain() {
« no previous file with comments | « no previous file | extensions/renderer/module_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698