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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp

Issue 2725883002: bindings: Add ToV8() overload for HeapVector<std::pair<String, T>>. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ToV8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp b/third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp
index b539ccf75d98cf5acdd45601ece98c42a5527083..24aceb62c10f95cf59a79d2473ca3a7fda19c704 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp
@@ -204,15 +204,15 @@ TEST(ToV8Test, basicTypeVectors) {
TEST_TOV8("true,true,false", boolVector);
}
-TEST(ToV8Test, dictionaryVector) {
+TEST(ToV8Test, pairVector) {
V8TestingScope scope;
- Vector<std::pair<String, int>> dictionary;
- dictionary.push_back(std::make_pair("one", 1));
- dictionary.push_back(std::make_pair("two", 2));
- TEST_TOV8("[object Object]", dictionary);
+ Vector<std::pair<String, int>> pairVector;
+ pairVector.push_back(std::make_pair("one", 1));
+ pairVector.push_back(std::make_pair("two", 2));
+ TEST_TOV8("[object Object]", pairVector);
v8::Local<v8::Context> context = scope.getScriptState()->context();
v8::Local<v8::Object> result =
- ToV8(dictionary, context->Global(), scope.isolate())
+ ToV8(pairVector, context->Global(), scope.isolate())
->ToObject(context)
.ToLocalChecked();
v8::Local<v8::Value> one =
@@ -223,6 +223,30 @@ TEST(ToV8Test, dictionaryVector) {
EXPECT_EQ(2, two->NumberValue(context).FromJust());
}
+TEST(ToV8Test, pairHeapVector) {
+ V8TestingScope scope;
+ HeapVector<std::pair<String, Member<GarbageCollectedScriptWrappable>>>
+ pairHeapVector;
+ pairHeapVector.push_back(
+ std::make_pair("one", new GarbageCollectedScriptWrappable("foo")));
+ pairHeapVector.push_back(
+ std::make_pair("two", new GarbageCollectedScriptWrappable("bar")));
+ TEST_TOV8("[object Object]", pairHeapVector);
+ v8::Local<v8::Context> context = scope.getScriptState()->context();
+ v8::Local<v8::Object> result =
+ ToV8(pairHeapVector, context->Global(), scope.isolate())
+ ->ToObject(context)
+ .ToLocalChecked();
+ v8::Local<v8::Value> one =
+ result->Get(context, v8String(scope.isolate(), "one")).ToLocalChecked();
+ EXPECT_TRUE(one->IsObject());
+ EXPECT_EQ(String("foo"), toCoreString(one->ToString()));
+ v8::Local<v8::Value> two =
+ result->Get(context, v8String(scope.isolate(), "two")).ToLocalChecked();
+ EXPECT_TRUE(two->IsObject());
+ EXPECT_EQ(String("bar"), toCoreString(two->ToString()));
+}
+
TEST(ToV8Test, stringVectorVector) {
V8TestingScope scope;
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ToV8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698