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

Side by Side Diff: content/renderer/v8_value_converter_impl_unittest.cc

Issue 10387055: Support optional arguments in SendRequestNatives::StartRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated copyright header Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <cmath> 5 #include <cmath>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "content/renderer/v8_value_converter_impl.h" 9 #include "content/renderer/v8_value_converter_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "v8/include/v8.h" 11 #include "v8/include/v8.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 v8::HandleScope handle_scope; 286 v8::HandleScope handle_scope;
287 287
288 v8::Handle<v8::RegExp> regex( 288 v8::Handle<v8::RegExp> regex(
289 v8::RegExp::New(v8::String::New("."), v8::RegExp::kNone)); 289 v8::RegExp::New(v8::String::New("."), v8::RegExp::kNone));
290 290
291 V8ValueConverterImpl converter; 291 V8ValueConverterImpl converter;
292 TestWeirdType(converter, v8::Undefined(), Value::TYPE_NULL, NULL); 292 TestWeirdType(converter, v8::Undefined(), Value::TYPE_NULL, NULL);
293 TestWeirdType(converter, v8::Date::New(1000), Value::TYPE_DICTIONARY, NULL); 293 TestWeirdType(converter, v8::Date::New(1000), Value::TYPE_DICTIONARY, NULL);
294 TestWeirdType(converter, regex, Value::TYPE_DICTIONARY, NULL); 294 TestWeirdType(converter, regex, Value::TYPE_DICTIONARY, NULL);
295 295
296 converter.set_allow_undefined(true); 296 converter.SetAllowUndefined(true);
297 TestWeirdType(converter, v8::Undefined(), Value::TYPE_NULL, NULL); 297 TestWeirdType(converter, v8::Undefined(), Value::TYPE_NULL, NULL);
298 298
299 converter.set_allow_date(true); 299 converter.SetAllowDate(true);
300 TestWeirdType(converter, v8::Date::New(1000), Value::TYPE_DOUBLE, 300 TestWeirdType(converter, v8::Date::New(1000), Value::TYPE_DOUBLE,
301 Value::CreateDoubleValue(1)); 301 Value::CreateDoubleValue(1));
302 302
303 converter.set_allow_regexp(true); 303 converter.SetAllowRegexp(true);
304 TestWeirdType(converter, regex, Value::TYPE_STRING, 304 TestWeirdType(converter, regex, Value::TYPE_STRING,
305 Value::CreateStringValue("/./")); 305 Value::CreateStringValue("/./"));
306 } 306 }
307 307
308 TEST_F(V8ValueConverterImplTest, Prototype) { 308 TEST_F(V8ValueConverterImplTest, Prototype) {
309 v8::Context::Scope context_scope(context_); 309 v8::Context::Scope context_scope(context_);
310 v8::HandleScope handle_scope; 310 v8::HandleScope handle_scope;
311 311
312 const char* source = "(function() {" 312 const char* source = "(function() {"
313 "Object.prototype.foo = 'foo';" 313 "Object.prototype.foo = 'foo';"
314 "return {};" 314 "return {};"
315 "})();"; 315 "})();";
316 316
317 v8::Handle<v8::Script> script(v8::Script::New(v8::String::New(source))); 317 v8::Handle<v8::Script> script(v8::Script::New(v8::String::New(source)));
318 v8::Handle<v8::Object> object = script->Run().As<v8::Object>(); 318 v8::Handle<v8::Object> object = script->Run().As<v8::Object>();
319 ASSERT_FALSE(object.IsEmpty()); 319 ASSERT_FALSE(object.IsEmpty());
320 320
321 V8ValueConverterImpl converter; 321 V8ValueConverterImpl converter;
322 scoped_ptr<DictionaryValue> result( 322 scoped_ptr<DictionaryValue> result(
323 static_cast<DictionaryValue*>(converter.FromV8Value(object, context_))); 323 static_cast<DictionaryValue*>(converter.FromV8Value(object, context_)));
324 ASSERT_TRUE(result.get()); 324 ASSERT_TRUE(result.get());
325 EXPECT_EQ(0u, result->size()); 325 EXPECT_EQ(0u, result->size());
326 } 326 }
OLDNEW
« content/public/renderer/v8_value_converter.h ('K') | « content/renderer/v8_value_converter_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698