Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: extensions/renderer/native_extension_bindings_system_unittest.cc

Issue 2901383008: [Extenisons Bindings] Support `unmanaged` property for events (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/chrome_setting.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 } 1012 }
1013 1013
1014 { 1014 {
1015 // Trying to run a chrome.idle function should now succeed. 1015 // Trying to run a chrome.idle function should now succeed.
1016 v8::Local<v8::Value> args[] = {initial_idle}; 1016 v8::Local<v8::Value> args[] = {initial_idle};
1017 RunFunction(run_idle, context, arraysize(args), args); 1017 RunFunction(run_idle, context, arraysize(args), args);
1018 EXPECT_EQ("idle.queryState", last_params().name); 1018 EXPECT_EQ("idle.queryState", last_params().name);
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 TEST_F(NativeExtensionBindingsSystemUnittest, UnmanagedEvents) {
1023 InitEventChangeHandler();
1024
1025 scoped_refptr<Extension> extension =
1026 CreateExtension("foo", ItemType::EXTENSION, std::vector<std::string>());
1027 RegisterExtension(extension->id());
1028
1029 v8::HandleScope handle_scope(isolate());
1030 v8::Local<v8::Context> context = MainContext();
1031 ScriptContext* script_context = CreateScriptContext(
1032 context, extension.get(), Feature::BLESSED_EXTENSION_CONTEXT);
1033 script_context->set_url(extension->url());
1034
1035 bindings_system()->UpdateBindingsForContext(script_context);
1036
1037 const char kAddListeners[] =
1038 "(function() {\n"
1039 " chrome.runtime.onMessage.addListener(function() {});\n"
1040 " chrome.runtime.onConnect.addListener(function() {});\n"
1041 "});";
1042
1043 v8::Local<v8::Function> add_listeners =
1044 FunctionFromString(context, kAddListeners);
1045 RunFunctionOnGlobal(add_listeners, context, 0, nullptr);
1046
1047 // We should have no notifications for event listeners added (since the
1048 // mock is a strict mock, this will fail if anything was called).
1049 ::testing::Mock::VerifyAndClearExpectations(event_change_handler());
1050 }
1051
1022 } // namespace extensions 1052 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/chrome_setting.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698