| 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 "extensions/renderer/native_extension_bindings_system.h" | 5 #include "extensions/renderer/native_extension_bindings_system.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "components/crx_file/id_util.h" | 10 #include "components/crx_file/id_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 script_context_set_ = base::MakeUnique<ScriptContextSet>(&extension_ids_); | 92 script_context_set_ = base::MakeUnique<ScriptContextSet>(&extension_ids_); |
| 93 bindings_system_ = base::MakeUnique<NativeExtensionBindingsSystem>( | 93 bindings_system_ = base::MakeUnique<NativeExtensionBindingsSystem>( |
| 94 base::Bind(&NativeExtensionBindingsSystemUnittest::MockSendRequestIPC, | 94 base::Bind(&NativeExtensionBindingsSystemUnittest::MockSendRequestIPC, |
| 95 base::Unretained(this)), | 95 base::Unretained(this)), |
| 96 base::Bind(&NativeExtensionBindingsSystemUnittest::MockSendListenerIPC, | 96 base::Bind(&NativeExtensionBindingsSystemUnittest::MockSendListenerIPC, |
| 97 base::Unretained(this))); | 97 base::Unretained(this))); |
| 98 APIBindingTest::SetUp(); | 98 APIBindingTest::SetUp(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void TearDown() override { | 101 void TearDown() override { |
| 102 for (const auto& context : raw_script_contexts_) | 102 for (auto* context : raw_script_contexts_) |
| 103 script_context_set_->Remove(context); | 103 script_context_set_->Remove(context); |
| 104 base::RunLoop().RunUntilIdle(); | 104 base::RunLoop().RunUntilIdle(); |
| 105 script_context_set_.reset(); | 105 script_context_set_.reset(); |
| 106 bindings_system_.reset(); | 106 bindings_system_.reset(); |
| 107 APIBindingTest::TearDown(); | 107 APIBindingTest::TearDown(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void MockSendRequestIPC(ScriptContext* context, | 110 void MockSendRequestIPC(ScriptContext* context, |
| 111 const ExtensionHostMsg_Request_Params& params) { | 111 const ExtensionHostMsg_Request_Params& params) { |
| 112 last_params_.name = params.name; | 112 last_params_.name = params.name; |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // Respond and validate. | 647 // Respond and validate. |
| 648 bindings_system()->HandleResponse(last_params().request_id, true, | 648 bindings_system()->HandleResponse(last_params().request_id, true, |
| 649 base::ListValue(), "Some API Error"); | 649 base::ListValue(), "Some API Error"); |
| 650 | 650 |
| 651 EXPECT_EQ("\"Some API Error\"", | 651 EXPECT_EQ("\"Some API Error\"", |
| 652 GetStringPropertyFromObject(context->Global(), context, | 652 GetStringPropertyFromObject(context->Global(), context, |
| 653 "lastErrorMessage")); | 653 "lastErrorMessage")); |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace extensions | 656 } // namespace extensions |
| OLD | NEW |