| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/bindings/api_binding_js_util.h" | 5 #include "extensions/renderer/bindings/api_binding_js_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "extensions/renderer/bindings/api_binding_test_util.h" | 8 #include "extensions/renderer/bindings/api_binding_test_util.h" |
| 9 #include "extensions/renderer/bindings/api_bindings_system.h" | 9 #include "extensions/renderer/bindings/api_bindings_system.h" |
| 10 #include "extensions/renderer/bindings/api_bindings_system_unittest.h" | 10 #include "extensions/renderer/bindings/api_bindings_system_unittest.h" |
| 11 #include "gin/handle.h" | 11 #include "gin/handle.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 class APIBindingJSUtilUnittest : public APIBindingsSystemTest { | 15 class APIBindingJSUtilUnittest : public APIBindingsSystemTest { |
| 16 protected: | 16 protected: |
| 17 APIBindingJSUtilUnittest() {} | 17 APIBindingJSUtilUnittest() {} |
| 18 ~APIBindingJSUtilUnittest() override {} | 18 ~APIBindingJSUtilUnittest() override {} |
| 19 | 19 |
| 20 gin::Handle<APIBindingJSUtil> CreateUtil() { | 20 gin::Handle<APIBindingJSUtil> CreateUtil() { |
| 21 return gin::CreateHandle( | 21 return gin::CreateHandle( |
| 22 isolate(), | 22 isolate(), |
| 23 new APIBindingJSUtil(bindings_system()->type_reference_map(), | 23 new APIBindingJSUtil(bindings_system()->type_reference_map(), |
| 24 bindings_system()->request_handler(), | 24 bindings_system()->request_handler(), |
| 25 bindings_system()->event_handler(), | 25 bindings_system()->event_handler(), |
| 26 base::Bind(&RunFunctionOnGlobalAndIgnoreResult))); | 26 base::Bind(&RunFunctionOnGlobalAndIgnoreResult))); |
| 27 } | 27 } |
| 28 | 28 |
| 29 v8::Local<v8::Object> GetLastErrorParent( | 29 v8::Local<v8::Object> GetLastErrorParent( |
| 30 v8::Local<v8::Context> context) override { | 30 v8::Local<v8::Context> context, |
| 31 v8::Local<v8::Object>* secondary_parent) override { |
| 31 return context->Global(); | 32 return context->Global(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 std::string GetExposedError(v8::Local<v8::Context> context) { | 35 std::string GetExposedError(v8::Local<v8::Context> context) { |
| 35 v8::Local<v8::Value> last_error = | 36 v8::Local<v8::Value> last_error = |
| 36 GetPropertyFromObject(context->Global(), context, "lastError"); | 37 GetPropertyFromObject(context->Global(), context, "lastError"); |
| 37 | 38 |
| 38 // Use ADD_FAILURE() to avoid messing up the return type with ASSERT. | 39 // Use ADD_FAILURE() to avoid messing up the return type with ASSERT. |
| 39 if (last_error.IsEmpty()) { | 40 if (last_error.IsEmpty()) { |
| 40 ADD_FAILURE(); | 41 ADD_FAILURE(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_EQ("alpha.functionWithCallback", last_request()->method_name); | 185 EXPECT_EQ("alpha.functionWithCallback", last_request()->method_name); |
| 185 EXPECT_EQ("[\"stringy\"]", ValueToString(*last_request()->arguments)); | 186 EXPECT_EQ("[\"stringy\"]", ValueToString(*last_request()->arguments)); |
| 186 EXPECT_EQ(binding::RequestThread::UI, last_request()->thread); | 187 EXPECT_EQ(binding::RequestThread::UI, last_request()->thread); |
| 187 bindings_system()->CompleteRequest(last_request()->request_id, | 188 bindings_system()->CompleteRequest(last_request()->request_id, |
| 188 base::ListValue(), std::string()); | 189 base::ListValue(), std::string()); |
| 189 EXPECT_EQ("true", GetStringPropertyFromObject(context->Global(), context, | 190 EXPECT_EQ("true", GetStringPropertyFromObject(context->Global(), context, |
| 190 "callbackCalled")); | 191 "callbackCalled")); |
| 191 } | 192 } |
| 192 | 193 |
| 193 } // namespace extensions | 194 } // namespace extensions |
| OLD | NEW |