| 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 "components/crx_file/id_util.h" | 9 #include "components/crx_file/id_util.h" |
| 10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 bindings_system_.reset(); | 68 bindings_system_.reset(); |
| 69 APIBindingTest::TearDown(); | 69 APIBindingTest::TearDown(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void MockSendIPC(ScriptContext* context, | 72 void MockSendIPC(ScriptContext* context, |
| 73 const ExtensionHostMsg_Request_Params& params) { | 73 const ExtensionHostMsg_Request_Params& params) { |
| 74 last_params_.name = params.name; | 74 last_params_.name = params.name; |
| 75 last_params_.arguments.Swap(params.arguments.CreateDeepCopy().get()); | 75 last_params_.arguments.Swap(params.arguments.CreateDeepCopy().get()); |
| 76 last_params_.extension_id = params.extension_id; | 76 last_params_.extension_id = params.extension_id; |
| 77 last_params_.source_url = params.source_url; | 77 last_params_.source_url = params.source_url; |
| 78 last_params_.source_tab_id = params.source_tab_id; | |
| 79 last_params_.request_id = params.request_id; | 78 last_params_.request_id = params.request_id; |
| 80 last_params_.has_callback = params.has_callback; | 79 last_params_.has_callback = params.has_callback; |
| 81 last_params_.user_gesture = params.user_gesture; | 80 last_params_.user_gesture = params.user_gesture; |
| 82 last_params_.worker_thread_id = params.worker_thread_id; | 81 last_params_.worker_thread_id = params.worker_thread_id; |
| 83 last_params_.service_worker_version_id = params.service_worker_version_id; | 82 last_params_.service_worker_version_id = params.service_worker_version_id; |
| 84 } | 83 } |
| 85 | 84 |
| 86 ScriptContext* CreateScriptContext(v8::Local<v8::Context> v8_context, | 85 ScriptContext* CreateScriptContext(v8::Local<v8::Context> v8_context, |
| 87 Extension* extension, | 86 Extension* extension, |
| 88 Feature::Context context_type) { | 87 Feature::Context context_type) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 165 |
| 167 v8::Local<v8::Function> call_idle_query_state = | 166 v8::Local<v8::Function> call_idle_query_state = |
| 168 FunctionFromString(context, kCallIdleQueryState); | 167 FunctionFromString(context, kCallIdleQueryState); |
| 169 RunFunctionOnGlobal(call_idle_query_state, context, 0, nullptr); | 168 RunFunctionOnGlobal(call_idle_query_state, context, 0, nullptr); |
| 170 } | 169 } |
| 171 | 170 |
| 172 // Validate the params that would be sent to the browser. | 171 // Validate the params that would be sent to the browser. |
| 173 EXPECT_EQ(extension->id(), last_params().extension_id); | 172 EXPECT_EQ(extension->id(), last_params().extension_id); |
| 174 EXPECT_EQ("idle.queryState", last_params().name); | 173 EXPECT_EQ("idle.queryState", last_params().name); |
| 175 EXPECT_EQ(extension->url(), last_params().source_url); | 174 EXPECT_EQ(extension->url(), last_params().source_url); |
| 176 EXPECT_EQ(-1, last_params().source_tab_id); | |
| 177 EXPECT_TRUE(last_params().has_callback); | 175 EXPECT_TRUE(last_params().has_callback); |
| 178 EXPECT_TRUE( | 176 EXPECT_TRUE( |
| 179 last_params().arguments.Equals(ListValueFromString("[30]").get())); | 177 last_params().arguments.Equals(ListValueFromString("[30]").get())); |
| 180 | 178 |
| 181 // Respond and validate. | 179 // Respond and validate. |
| 182 bindings_system()->HandleResponse(last_params().request_id, true, | 180 bindings_system()->HandleResponse(last_params().request_id, true, |
| 183 *ListValueFromString("['active']"), | 181 *ListValueFromString("['active']"), |
| 184 std::string()); | 182 std::string()); |
| 185 | 183 |
| 186 std::unique_ptr<base::Value> result_value = GetBaseValuePropertyFromObject( | 184 std::unique_ptr<base::Value> result_value = GetBaseValuePropertyFromObject( |
| 187 context->Global(), context, "responseState"); | 185 context->Global(), context, "responseState"); |
| 188 ASSERT_TRUE(result_value); | 186 ASSERT_TRUE(result_value); |
| 189 EXPECT_EQ("\"active\"", ValueToString(*result_value)); | 187 EXPECT_EQ("\"active\"", ValueToString(*result_value)); |
| 190 } | 188 } |
| 191 | 189 |
| 192 } // namespace extensions | 190 } // namespace extensions |
| OLD | NEW |