| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "base/optional.h" | 7 #include "base/optional.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "extensions/renderer/bindings/api_binding_test.h" | 10 #include "extensions/renderer/bindings/api_binding_test.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ASSERT_TRUE(thread); | 366 ASSERT_TRUE(thread); |
| 367 EXPECT_EQ(binding::RequestThread::IO, *thread); | 367 EXPECT_EQ(binding::RequestThread::IO, *thread); |
| 368 thread.reset(); | 368 thread.reset(); |
| 369 } | 369 } |
| 370 | 370 |
| 371 TEST_F(APIRequestHandlerTest, SettingLastError) { | 371 TEST_F(APIRequestHandlerTest, SettingLastError) { |
| 372 v8::HandleScope handle_scope(isolate()); | 372 v8::HandleScope handle_scope(isolate()); |
| 373 v8::Local<v8::Context> context = MainContext(); | 373 v8::Local<v8::Context> context = MainContext(); |
| 374 | 374 |
| 375 base::Optional<std::string> logged_error; | 375 base::Optional<std::string> logged_error; |
| 376 auto get_parent = [](v8::Local<v8::Context> context) { | 376 auto get_parent = [](v8::Local<v8::Context> context, |
| 377 v8::Local<v8::Object>* secondary_parent) { |
| 377 return context->Global(); | 378 return context->Global(); |
| 378 }; | 379 }; |
| 379 | 380 |
| 380 auto log_error = [](base::Optional<std::string>* logged_error, | 381 auto log_error = [](base::Optional<std::string>* logged_error, |
| 381 v8::Local<v8::Context> context, | 382 v8::Local<v8::Context> context, |
| 382 const std::string& error) { *logged_error = error; }; | 383 const std::string& error) { *logged_error = error; }; |
| 383 | 384 |
| 384 APIRequestHandler request_handler( | 385 APIRequestHandler request_handler( |
| 385 base::Bind(&DoNothingWithRequest), | 386 base::Bind(&DoNothingWithRequest), |
| 386 base::Bind(&APIRequestHandlerTest::RunJS, base::Unretained(this)), | 387 base::Bind(&APIRequestHandlerTest::RunJS, base::Unretained(this)), |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 std::string()); | 480 std::string()); |
| 480 | 481 |
| 481 EXPECT_EQ(ReplaceSingleQuotes(kArguments), | 482 EXPECT_EQ(ReplaceSingleQuotes(kArguments), |
| 482 GetStringPropertyFromObject(context->Global(), context, "result")); | 483 GetStringPropertyFromObject(context->Global(), context, "result")); |
| 483 | 484 |
| 484 EXPECT_TRUE(request_handler.GetPendingRequestIdsForTesting().empty()); | 485 EXPECT_TRUE(request_handler.GetPendingRequestIdsForTesting().empty()); |
| 485 EXPECT_FALSE(dispatched_request); | 486 EXPECT_FALSE(dispatched_request); |
| 486 } | 487 } |
| 487 | 488 |
| 488 } // namespace extensions | 489 } // namespace extensions |
| OLD | NEW |