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

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

Issue 2615773002: [Extensions Bindings] Add enum support (Closed)
Patch Set: nits Created 3 years, 11 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/argument_spec.h ('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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 v8::Local<v8::Value> chrome = 141 v8::Local<v8::Value> chrome =
142 GetPropertyFromObject(context->Global(), context, "chrome"); 142 GetPropertyFromObject(context->Global(), context, "chrome");
143 ASSERT_FALSE(chrome.IsEmpty()); 143 ASSERT_FALSE(chrome.IsEmpty());
144 ASSERT_TRUE(chrome->IsObject()); 144 ASSERT_TRUE(chrome->IsObject());
145 145
146 v8::Local<v8::Value> idle = GetPropertyFromObject( 146 v8::Local<v8::Value> idle = GetPropertyFromObject(
147 v8::Local<v8::Object>::Cast(chrome), context, "idle"); 147 v8::Local<v8::Object>::Cast(chrome), context, "idle");
148 ASSERT_FALSE(idle.IsEmpty()); 148 ASSERT_FALSE(idle.IsEmpty());
149 ASSERT_TRUE(idle->IsObject()); 149 ASSERT_TRUE(idle->IsObject());
150 150
151 v8::Local<v8::Value> idle_query_state = GetPropertyFromObject( 151 v8::Local<v8::Object> idle_object = v8::Local<v8::Object>::Cast(idle);
152 v8::Local<v8::Object>::Cast(idle), context, "queryState"); 152 v8::Local<v8::Value> idle_query_state =
153 GetPropertyFromObject(idle_object, context, "queryState");
153 ASSERT_FALSE(idle_query_state.IsEmpty()); 154 ASSERT_FALSE(idle_query_state.IsEmpty());
154 155
156 EXPECT_EQ(ReplaceSingleQuotes(
157 "{'ACTIVE':'active','IDLE':'idle','LOCKED':'locked'}"),
158 GetStringPropertyFromObject(idle_object, context, "IdleState"));
159
155 { 160 {
156 // Try calling the function with an invalid invocation - an error should be 161 // Try calling the function with an invalid invocation - an error should be
157 // thrown. 162 // thrown.
158 const char kCallIdleQueryStateInvalid[] = 163 const char kCallIdleQueryStateInvalid[] =
159 "(function() {\n" 164 "(function() {\n"
160 " chrome.idle.queryState('foo', function(state) {\n" 165 " chrome.idle.queryState('foo', function(state) {\n"
161 " this.responseState = state;\n" 166 " this.responseState = state;\n"
162 " });\n" 167 " });\n"
163 "});"; 168 "});";
164 v8::Local<v8::Function> function = 169 v8::Local<v8::Function> function =
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 EXPECT_EQ("20", GetStringPropertyFromObject(global, context, "intervalArg")); 371 EXPECT_EQ("20", GetStringPropertyFromObject(global, context, "intervalArg"));
367 EXPECT_EQ(extension->id(), last_params().extension_id); 372 EXPECT_EQ(extension->id(), last_params().extension_id);
368 EXPECT_EQ("idle.setDetectionInterval", last_params().name); 373 EXPECT_EQ("idle.setDetectionInterval", last_params().name);
369 EXPECT_EQ(extension->url(), last_params().source_url); 374 EXPECT_EQ(extension->url(), last_params().source_url);
370 EXPECT_FALSE(last_params().has_callback); 375 EXPECT_FALSE(last_params().has_callback);
371 EXPECT_TRUE( 376 EXPECT_TRUE(
372 last_params().arguments.Equals(ListValueFromString("[50]").get())); 377 last_params().arguments.Equals(ListValueFromString("[50]").get()));
373 } 378 }
374 379
375 } // namespace extensions 380 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/argument_spec.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698