| 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" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/extension_builder.h" | 12 #include "extensions/common/extension_builder.h" |
| 13 #include "extensions/common/extension_messages.h" | 13 #include "extensions/common/extension_messages.h" |
| 14 #include "extensions/common/manifest.h" | 14 #include "extensions/common/manifest.h" |
| 15 #include "extensions/common/permissions/permissions_data.h" | 15 #include "extensions/common/permissions/permissions_data.h" |
| 16 #include "extensions/common/value_builder.h" | 16 #include "extensions/common/value_builder.h" |
| 17 #include "extensions/renderer/bindings/api_binding_test.h" | 17 #include "extensions/renderer/bindings/api_binding_test.h" |
| 18 #include "extensions/renderer/bindings/api_binding_test_util.h" | 18 #include "extensions/renderer/bindings/api_binding_test_util.h" |
| 19 #include "extensions/renderer/bindings/api_invocation_errors.h" | 19 #include "extensions/renderer/bindings/api_invocation_errors.h" |
| 20 #include "extensions/renderer/module_system.h" | 20 #include "extensions/renderer/module_system.h" |
| 21 #include "extensions/renderer/safe_builtins.h" | 21 #include "extensions/renderer/safe_builtins.h" |
| 22 #include "extensions/renderer/script_context.h" | 22 #include "extensions/renderer/script_context.h" |
| 23 #include "extensions/renderer/script_context_set.h" | 23 #include "extensions/renderer/script_context_set.h" |
| 24 #include "extensions/renderer/string_source_map.h" | 24 #include "extensions/renderer/string_source_map.h" |
| 25 #include "extensions/renderer/test_extensions_renderer_client.h" |
| 25 #include "extensions/renderer/test_v8_extension_configuration.h" | 26 #include "extensions/renderer/test_v8_extension_configuration.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 27 | 28 |
| 28 namespace extensions { | 29 namespace extensions { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 enum class ItemType { | 33 enum class ItemType { |
| 33 EXTENSION, | 34 EXTENSION, |
| 34 PLATFORM_APP, | 35 PLATFORM_APP, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 private: | 197 private: |
| 197 ExtensionIdSet extension_ids_; | 198 ExtensionIdSet extension_ids_; |
| 198 std::unique_ptr<ScriptContextSet> script_context_set_; | 199 std::unique_ptr<ScriptContextSet> script_context_set_; |
| 199 std::vector<ScriptContext*> raw_script_contexts_; | 200 std::vector<ScriptContext*> raw_script_contexts_; |
| 200 std::unique_ptr<NativeExtensionBindingsSystem> bindings_system_; | 201 std::unique_ptr<NativeExtensionBindingsSystem> bindings_system_; |
| 201 | 202 |
| 202 ExtensionHostMsg_Request_Params last_params_; | 203 ExtensionHostMsg_Request_Params last_params_; |
| 203 std::unique_ptr<MockEventChangeHandler> event_change_handler_; | 204 std::unique_ptr<MockEventChangeHandler> event_change_handler_; |
| 204 | 205 |
| 205 StringSourceMap source_map_; | 206 StringSourceMap source_map_; |
| 207 TestExtensionsRendererClient renderer_client_; |
| 206 | 208 |
| 207 DISALLOW_COPY_AND_ASSIGN(NativeExtensionBindingsSystemUnittest); | 209 DISALLOW_COPY_AND_ASSIGN(NativeExtensionBindingsSystemUnittest); |
| 208 }; | 210 }; |
| 209 | 211 |
| 210 TEST_F(NativeExtensionBindingsSystemUnittest, Basic) { | 212 TEST_F(NativeExtensionBindingsSystemUnittest, Basic) { |
| 211 scoped_refptr<Extension> extension = CreateExtension( | 213 scoped_refptr<Extension> extension = CreateExtension( |
| 212 "foo", ItemType::EXTENSION, {"idle", "power", "webRequest"}); | 214 "foo", ItemType::EXTENSION, {"idle", "power", "webRequest"}); |
| 213 RegisterExtension(extension->id()); | 215 RegisterExtension(extension->id()); |
| 214 | 216 |
| 215 v8::HandleScope handle_scope(isolate()); | 217 v8::HandleScope handle_scope(isolate()); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 v8::Local<v8::Function> add_listeners = | 1049 v8::Local<v8::Function> add_listeners = |
| 1048 FunctionFromString(context, kAddListeners); | 1050 FunctionFromString(context, kAddListeners); |
| 1049 RunFunctionOnGlobal(add_listeners, context, 0, nullptr); | 1051 RunFunctionOnGlobal(add_listeners, context, 0, nullptr); |
| 1050 | 1052 |
| 1051 // We should have no notifications for event listeners added (since the | 1053 // We should have no notifications for event listeners added (since the |
| 1052 // mock is a strict mock, this will fail if anything was called). | 1054 // mock is a strict mock, this will fail if anything was called). |
| 1053 ::testing::Mock::VerifyAndClearExpectations(event_change_handler()); | 1055 ::testing::Mock::VerifyAndClearExpectations(event_change_handler()); |
| 1054 } | 1056 } |
| 1055 | 1057 |
| 1056 } // namespace extensions | 1058 } // namespace extensions |
| OLD | NEW |